Change URL subdirectory and filename for 437 file requests
I have 437 URL requests which were static files on Movable Type, which can only be viewed on WordPress and in a different subfolder, with modified filenames. I have tried for days to make Rewrite and Redirect work, but no success.
Here is an example in my root
.htaccess
file of what I need to do (this didn't work, though).
RewriteRule
http://voidnow.org/archives/2012/08/divided-america.php
to
http://voidnow.org/WP-Void/2012/08/divided_america/
There are 4 changes to make:
-
subdirectory
/archives/changed to/WP-Void/ -
file-name-with-hyphenschanged tofile_name_with_underscores -
.phplopped off filename -
slash added to end of line
I have the following lines at the top of my root
.htaccess
:
Options -Indexes +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
Please note that .php files no longer exist in the archives subdirectory. Not sure if that makes a difference, but, error logs for the failed rewrites begin by stating that the requested file is not found in the /archives/ subdirectory.
Solutions
This should work for you:
RewriteEngine on
RewriteRule ^archives/([0-9]{4})/([0-9]{2})/(.*)-(.*).php /WP-Void/$1/$2/$3_$4/ [R=301,L]
it should redirect pages from:
http://voidnow.org/archives/2012/08/divided-america.php
to
http://voidnow.org/WP-Void/2012/08/divided_america/