Hello - I've moved my Wordpress blog to the root directory and decided to eliminate the post id from the permalink. So now I'm trying to figure out the right .htaccess statement to use to redirect thusly: From www.mysite.com/blog/157/best-post.php/ to www.mysite.com/best-post.php/ I've found guidance on going to www.mysite.com/157/best-post.php/ but can't figure out how to get rid of the post id number. Can someone help out an .htaccess novice? Thanks
I would try : Options +FollowSymlinks RewriteEngine on RewriteRule ^blog\/\d+\/(.*)$ /$1 [QSA,L,R=301] Code (markup): Jean-Luc
Jean - I tried this, but no go. The following: RewriteEngine On RewriteRule ^blog/(.*)$ $1 [L,redirect=permanent] Code (markup): gets me from www.mysite.com/blog/157/best-post.php/ to www.mysite.com/157/best-post.php/ Is there something to be added that would delete the /157? I tried variations of /\d+\/ from your post but couldn't get it to work.
To eliminate the /157 : RewriteRule ^blog\/\d+\/(.*)$ $1 [L,redirect=permanent] Code (markup): \/ should be used for a / in the left part. \d+ means any number Jean-Luc
GRRRR! Still no luck. I probably should have noted that I'm using 1and1 hosting which I know has its quirks. When I tried RewriteRule ^blog\/\d+\/(.*)$ $1 [L,redirect=permanent] Code (markup): the result goes back to: www.mysite.com/blog/157/best-post.php/ This seems to happen with all changes I try after the "blog/" in RewriteRule ^heloc-blog/(.*)$ $1 [L,redirect=permanent] Here's some of the trial and error stuff I've tried w/o luck: RewriteRule ^blog\/\d+\/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog\/\d+/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/\d+(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/d+(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog\d+(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/\d+(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/(\d+)(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/(d+)/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/\d+(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog\(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/\d+/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/\d+\/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog\/\d+\/(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/(\d+)(.*)$ $1 [L,redirect=permanent] RewriteRule ^blog/(.*)$ $1 [L,redirect=permanent] Any other ideas?
That Did It! Using Bruno's suggestion but replacing the initial / with ^ does the trick: RewriteRule ^blog/[0-9]+/(.*) /$1 [L,redirect=permanent] Code (markup): Many thanks to Jean and Bruno for taking time to help. Hope I can pay forward the favor.