Forum Moderators: phranque
RewriteCond %(SERVER_NAME) ^www.site2.com.*
RewriteRule (.*)$ www.site1.com/page2 [R=301,L]
I think the 301 directive might indicate that I'm attempting to use mod_alias but something else is wrong with the syntax I'm using because no matter what I do the request for www.site2.com is being routed to www.site1.com rather than www.site1.com/page2. Any help would be greatly appreciated.
Thank you
However, something more fundamental comes to mind. Do you need a redirect or a rewrite? Which URL should users be using and seeing for that content?
A redirect forces the user to see a different URL before the content is served. A rewrite connects their request to the content at a location different to that implied by the URL, and without revealing what that location actually is.
There have been several similar topics in the last few days where longer examples can be found.
If you simply move content inside the filesystem of your server, then there is no need to change URLs; Use an intenal rewrite instead, to tell the server where it should now look to find the content associated with the pre-existing URLs.
If you are co-hosting different sites in the same filespace, then again, there is no need to expose your internal filesytem architecture in a redirected URL. Simply internally-rewrite the requests for the pre-existing URLs to the correct location in the filesystem.
If, however, all of the sites' content is identical, then best practice is to externally 301-redirect all non-canonical URLs to the canonical URLs, and link only to one domain on the Web. The alternate domains can be used in print, radio, or TV advertising, but should not be promoted on the Web; Search engines take a dim view of trying to make the same content rank on multiple domains. In addition, the multiple sites compete against each other for ranking.
External redirect syntax:
RewriteRule URL-path-pattern http-or-https:optional-port-number//domain/substitution-URL-path [R=301,L] Internal rewrite syntax:
RewriteRule URL-path-pattern /substitution-filepath [L] Jim
[edited by: jdMorgan at 6:04 pm (utc) on Feb. 24, 2009]