【发布时间】:2016-10-27 20:52:19
【问题描述】:
我有这样的 url 结构
http://www.domain.dom/blog/%category%/%postname%/
在主题functions.php中遵循规则
function wpa58471_category_base() {
// Remember to flush the rules once manually after you added this code!
add_rewrite_rule(
// The regex to match the incoming URL
'blog/([^/]+)/([^/]+)/([^/]+)(/[0-9]+)?/?$',
// The resulting internal URL
'index.php?category_name=$matches[1]/$matches[2]&name=$matches[3]&paged=$matches[4]',
// Add the rule to the top of the rewrite list
'top' );
}
在此站点上找到的代码
所以现在浏览器中的 url 看起来像这样:
http://www.domain.dom/blog/cars/new-car-on-market/
问题:
当用户想要浏览汽车类别中的所有帖子时,网址是:
http://www.domain.dom/blog/category/cars/
我想隐藏 /category/ 部分。有可能吗?
谢谢
【问题讨论】:
标签: php wordpress apache mod-rewrite