Support » Fixing WordPress » Apache rewrite rule not working in WP 2.6

  • I had a rewrite rule that rewrote our old permalink structure (/YYYY/MM/DD/post-id) to the canonical ?p=post-id version. It didn’t redirect, just rewrote.

    After upgrading to 2.6.3 however, that rewrite doesn’t work. The old permalinks now give 404 errors. I’ve been able to fix it temporarily by changing the rewrite to a 302 redirect, but that’s not the ideal solution because what the browsers gets now is *two* redirects; my 302 redirect to the ?p=post-id URL, and then a WordPress-provided 301 redirect to the new permalink.

    Does anybody know what I need to do to get internal rewriting working again? Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • It’s hard to say what the problem is without knowing your specific rules. Post the contents of your .htaccess.

    Thanks Otto!

    Here’s the rewrite that used to work in 2.5, but no longer does after the upgrade to 2.6.3;

    RewriteEngine On
    RewriteBase /
    RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/00([0-9]*)/?$ /?p=$1 [L]

    what we’ve done for now is change the rule to use a 302 redirect;

    RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/00([0-9]*)/?$ /?p=$1 [R=302,L]

    That “works”, but it results in not just the initial 302 redirect, but a subsequent 301 to the new permalink (as you probably know), so it’s not a permanent fix (we hope!).

    Thanks again.


    Get rid of the [L] (and the R=302 for that matter), and make sure your rules comes before your normal WordPress .htaccess rules (the whole section, don’t try to integrate them).

    A [L] (Last) modifier causes URL rewriting to stop. You don’t want it to stop there, you want it to continue into WordPress with the modified URL.

    Ok, thanks. Unfortunately, I made that change but the problem persists. Here’s the full, revised .htaccess file;

    # Rewrite old custom permalink structure to canonical post-id form
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/00([0-9]*)/?$ /?p=$1

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

    # END WordPress

    Hmm.. What happens if you simply take your rule out completely? Does it throw up a 404 page?

    Yep, still a 404, which I’d expect because the old permalink structure was a proprietary one. Weird eh?

    So fixing rewriting seems a dead end. 8-(

    Anybody else got any ideas about how I can avoid these two redirects? Two is two too many, but one would at least be an improvement. The only one-redirect solution that comes to mind is to generate the Redirect commands for all (~5000!) effected permalinks and stick those in .htaccess.


    I know a plugin exists that allows you to specify a secondary permalink string, which it uses to then redirect to the new permalinks, but I can’t find the damn thing.

    Ahh, here it is:

    No idea if that works with 2.6 or not, but it might do what you need.


    same problem here – i described it in following thread:



    I’d also appreciate some help in the matter.. can anyone enlighten us?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Apache rewrite rule not working in WP 2.6’ is closed to new replies.