Support » Fixing WordPress » Permalink changed, how to avoid 404??

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can add the following code to your .htaccess file, before RewriteCond %{REQUEST_FILENAME} !-f:

    RewriteRule /[a-zA-Z0-9_-]+/([0-9]+) /index.php?p=$1 [R=301,L]

    Not sure it will work though.

    Thanks it worked, but with a little modification to your code:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule /[a-zA-Z0-9_-]+/([0-9]+)$ /index.php?p=$1 [R=301,L]

    Thanks 🙂

    Ahh, you should also add /? before $, just in case*.
    Links with trailing (forward)slash wouldn’t work.
    http://wael.nasreddine.com/linux/tip/19/

    Thanks for the TIP 🙂

    Is this a generic fix? I just read this:

    “The best time to set up ‘Pretty Permalinks’ is the moment you install your blog because if you already have a bunch of existing posts, changing the permalink structure will make it so that your old links to those posts will result in page not found errors – to fix this you would need to edit the .htaccess file to set up permanent redirects for each post and page in the form of:
    Redirect 301 http://www.yoursite.com/index.php?p=2 http://www.yoursite.com/the-new-post-title.htm
    (source)

    Is this solution solving the problem he is addressing?

    I tried the following and got a 404 error when trying to use .htm or .html

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wp/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule /[a-zA-Z0-9_-]+/([0-9]+)$ /wp/index.php?p=$1 [R=301,L]
    </IfModule>
    
    # END WordPress

    Still need something that works with version 2.5.1

    Thanks!
    Leslie

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Permalink changed, how to avoid 404??’ is closed to new replies.