eMxyzptlk
Member
Posted 4 years ago #
Hello,
My permalink was '/%category%/%post_id%/', I have changed it to '/%year%/%monthnum%/%day%/%postname%.html' but now trying to access the old links lead to a 404, how can I keep the old system working just for compatibility while keeping the new permalink system in place ??
oh and BTW my blog is http://wael.nasreddine.com/ an example would be http://wael.nasreddine.com/2008/03/18/beyond-eye-candy.html which was http://wael.nasreddine.com/linux/tip/19
Thanks :)
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.
eMxyzptlk
Member
Posted 4 years ago #
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/
eMxyzptlk
Member
Posted 4 years ago #
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?
lesliekirk
Member
Posted 4 years ago #
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