Q: htaccess 301 from old site to new site I have a client domain with thousands of pages that are moving to a new domain. The naming convention of the .html has changed, and I know htaccess can handle this somehow.
Here's an example:
old site:
http://oldsite.com/state/cityname-index.html
new site:
http://newsite.com/state/computer-support-cityname-index.html
This is beyond my understanding at the moment. I'd appreciate a little help. Thanks!

A: If you want to redirect the old website pages to the new one, you can use rewriting like this :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com$ [NC]
RewriteRule ^([^/]+)/(.+)-index\.html$ http://newsite.com/$1/computer-support-$2-index.html [QSA,R=301]

The first line activates the rewriting in the htaccess.
the second one checks if the current request is for the old website.
if yes, the third line is activated, wich contains a regular expression and a new link to redirect to if that regular expression if matched, the [QSA,R=301] at the end are flags that will affect the rewrite rule.
This rule I wrote to you captures the state (first parentheses) and the cityname (second parentheses) and then it redirects to the new website replacing the $n (where n is the number of the parenthese from before) with the captured content.
The QSA flag (Query String Append) will add any parameter from the old site request to the new generated request.
The R=301 flag will generate a browser Redirection with code 301 (permanant redirect).
For more information about mod_rewrite see http://httpd.apache.org/docs/current/mod/mod_rewrite.html
