I've over 2000 HTML files that have reached Wordpress blog. I've the URL Map of Old_file.html and new wordpress URL.

I would like 301 redirect but don't wish to add 2000 lines to htaccess. Are you able to please suggest how to do this using PHP to ensure that when there's a request old url, the php script should research in to the database and redirect(301) towards the new URL ?

Thanks.

You may make your map a mod_rewrite rewrite map such as this:

# old    new
Old_file new-url

Then you need to simply register the rewrite map within the server or virtual host configuration:

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

And lastly set a guide that does the redirect (in both your server/virtual host configuration or perhaps an .htaccess file):

RewriteCond %{examplemap:$1} .+
RewriteRule ^/?(.+)\.html$ /blog/%0 [L,R=301]