Forum Moderators: phranque
I need to write the following RewriteRule, but am having no luck.
Old path on old server:
http://www.example.com/rs/2008/2/20/jaw-dropping-photosynth-demo.html
New path on new server:
http://www.example.com/2008/02/20/jaw-dropping-photosynth-demo/
Basically have to do the following:
-drop out the /rs/
-change the month from a 1 digit to a 2 digit
-Drop the ".html" at the end
-keep the post slug the same no matter the post (i.e. in this example "jaw-dropping-photosynth-demo")
Thank you for your help!
Brian
[edited by: jdMorgan at 4:40 pm (utc) on May 20, 2008]
[edit reason] example.com [/edit]
The only real difficulty here is making the one-digit month into a two-digit month when appropriate, but that's easily solved by making the first month-digit optional in the requested URL-path.
If this code goes in httpd.conf, conf.d, or some other server-configuration-level file, then something like:
RewriteRule ^/rs/([0-9]{4})/([01]?[0-9])/([0-3][0-9])/([^.]+)\.html$ http://www.example.com/$1/$2/$3/$4/ [R=301,L]
Also, this new rule should precede any existing WP-provided rules in .htaccess.
As a side-note, don't put that trailing slash on the new URL unless you absolutely have to -- It's a mild violation of the way things are supposed to work, in that "/jaw-dropping-photosynth-demo" is a file, whereas "/jaw-dropping-photosynth-demo/" is a directory (or the index page in that directory, e.g."/jaw-dropping-photosynth-demo/index.php". It's a subtle thing, but worth paying attention to. Plus you save a wasted "/" character on every post request to your server.
Jim