Using custom mod_rewrite without breaking wordpress permalinks

I am using a theme that uses posts for multiple pages, and the blog posts goes in a category called “blog”, I am using the permalinks setting “/%postname%”, and the blog menu url is “/category/blog”, how can I rewrite that to “/blog” without breaking the rest of the wp url rewrites?, my htaccess is the normal from wp:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Related posts

Leave a Reply

2 comments

  1. You don’t have to touch the Apache configuration for this, you can do this all from the WordPress rewrite system. But indeed, your general idea is correct: you should append ?cat=3 (or category_name=blog if you want to be even clearer). Remember that your blog archive can have multiple pages, maybe you want to handle this too.

    This is how I would do this from inside WordPress:

    add_action( 'init', 'wpse7379_init' );
    function wpse7379_init()
    {
        add_rewrite_rule(
            'blog(/page/([0-9]+))?/?$',
            'index.php?category_name=blog&paged=$matches[2]',
            'top'
        );
    }