Htaccess 301 redirection for multiple files
I am wondering if multiple entries in htaccess would work for a 301 redirect.
The problem I see is that the old site files have a "html" extension and are named differently, so a simple global redirect won't work, it must be one rule for the filename.
These sites receive 1,000 visits daily, so you need to be careful not to punish the search engine.
RewriteEngine On
RewriteBase /
RewriteRule ^file1\.html$ http://www.domain.com/file1.php [R=301,NC,L]
RewriteRule ^file2\.html$ http://www.domain.com/file2.php [R=301,NC,L]
RewriteRule ^file3\.html$ http://www.domain.com/file3.php [R=301,NC,L]
RewriteRule ^file4\.html$ http://www.domain.com/file4.php [R=301,NC,L]
Rewriting the php header will not work as the old files are html type.
source to share
I suppose you could use some kind of regex to reduce the number of different RewriteRules that you use, since they all look the same.
In your case, using just this might be okay:
RewriteRule ^(file1|file2|file3|file4)\.html$ http://www.metaboforte.com/$1.php [R=301,NC,L]
This way you know exactly what you want to rewrite; but only has 1 RewriteRule.
Or, a little more general:
RewriteRule ^file([0-9]*)\.html$ http://www.metaboforte.com/file$1.php [R=301,NC,L]
Which lets you define that you want to rewrite each XXYZ.html file with an XYZ number. (Since I used '*' no number at all would be taken into account by this rewrite rule, if you want at least one number you must use '+')
You can also do something even more general - not sure if you want this, but something like this:
RewriteRule ^(.*?)\.html$ http://www.metaboforte.com/$1.php [R=301,NC,L]
This is where you redirect anything ending in .html
source to share