向wordpress添加了自定义重写规则,它根本不起作用

时间:2014-10-16 12:35:41

标签: php wordpress mod-rewrite

function rewrite_support() {
    $wp_rewrite->flush_rules();
    add_rewrite_rule('^support/category/([^/]+)/?$','support-category/?category=$matches[1]','top');
}

add_action( 'init', 'rewrite_support');

这是不是有效的原因?我已将此代码包含在我的functions.php文件中。

/ support-category /?category = category name

应该重定向到:

/ support / category / category name

这似乎不起作用:

1 个答案:

答案 0 :(得分:0)

也许:

add_rewrite_rule('^support-category/([^/]+)/?$','index.php?pagename=support/category&category_name=$matches[1]','top');

add_rewrite_rule('^support/category/([^/]+)/?$','index.php?pagename=support-category&category_name=$matches[1]','top');