tags:

views:

27

answers:

1

Hi,

I have over 2000 HTML files that are now in Wordpress blog. I have the URL Map of Old_file.html and new wordpress URL.

I want 301 redirect but don't want to add 2000 lines to htaccess. Can you please suggest how to accomplish this using PHP so that when there is a request for old url, the php script should lookup into the database and redirect(301) to the new URL ?

Thanks.

+1  A: 

You can make your map a mod_rewrite rewrite map like this:

# old    new
Old_file new-url

Then you just need to register the rewrite map in the server or virtual host configuration:

RewriteMap examplemap txt:/path/to/file/map.txt

And finally set a rule that does the redirect (either in your server/virtual host configuration or an .htaccess file):

RewriteCond %{examplemap:$1} .+
RewriteRule ^/?(.+)\.html$ /blog/%0 [L,R=301]
Gumbo
So far getting internal server error...Registering Rewrite Map - Does this happen by including in .htaccess file or something else ?And why is the /blog/ for ?
Chetan
I think I know what Registering is now. Will look into it.
Chetan
@Chetan: `RewriteMap` can only be used in the server or virtual host configuration file.
Gumbo