Forum Moderators: phranque
I've got the following rewrite rules that my cms ( [drupal.org ]) uses:
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
The site has been in development but is now going to assume a URL of an existing site. We have to redirect all of their files (around 300) and I'm trying to figure out how to redirect in the .htaccess file.
Is there a way to do it with RewriteMap and a separate txt file?
Many thanks for your help,
Brett
You might be able to use this method in either httpd.conf or .htaccess: If the old files have any uniquely-identifying characteristics such as directory names, that can be used to advantage in reducing the number of required RewriteRules. For example, instead of redirecting each of 50 files in the directory "/dir" individually, you could simply redirect all files in that directory to a new directory-path:
RewriteRule ^dir/(.*)$ http://example.com/new_path/$1 [R=301,L]
RewriteRule ^dir/([^.])\.html$ http://example.com/new_path/new-$1.php [R=301,L]
RewriteRule ^dir/([^.])\.html$ http://example.com/script.php?oldname=$1 [R=301,L]
Look for commonalities in the file path at the directory level, subdirectory level, and procieeding down to the individual file. You may have to use individual redirects if the original site was disorganized, but if you get the backlinks updated, then you won't need to leave the redirects (or at least, all of the redirects) in place forever.
Jim