Simple wp_rewrite rule not working
-
With WP2.0, I wanted to replace my hacked-in mod_rewrite rules with wp_rewrite rules.
The mod_rewrite rules were as follows:
RewriteRule ^poetry/([^/]+)/?$ /index.php?name=$1 [QSA,L]
RewriteRule ^poetry/?$ /index.php?category_name=poetry [QSA,L]I replaced them with this in a plugin:
function cp_rewrite_rules ( $rules ) {
global $wp_rewrite;$new_rules['^poetry/(.+)$'] = '/index.php?name=$matches[1]';
$new_rules['^poetry/?$'] = '/index.php?category_name=poetry';return ( $rules + $new_rules );
}add_filter('rewrite_rules_array', 'cp_rewrite_rules');
The first rule works properly, showing me a post when I navigate to “/poetry/some-post-name”. The second one should show me the archives for the “poetry” category when I browse to “/poetry/”, but it actually just displays the “home” page.
Any idea what I’m doing wrong? Thanks.
- The topic ‘Simple wp_rewrite rule not working’ is closed to new replies.