Wordpress从网址结构隐藏类别

时间:2016-10-27 12:33:09

标签: php wordpress apache mod-rewrite

我有像这样的网址结构

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/

我想隐藏/分类/部分。有可能吗?

由于

1 个答案:

答案 0 :(得分:-1)