Forum Moderators: phranque
RedirectMatch permanent www\.domainA\.com/directory/file.html [domainB.com...]
I have multiple domains running under one IP and need to begin some 301s to fix some SEO issues.
Thanks.
In that case, then no, mod-alias does not 'see' domain names in the request, so it can't test for 'domainA' in the request.
Use mod_rewrite, and use a RewriteCond to examine HTTP_HOST to determine whether the requested hostname is one which should be redirected.
Jim
For use in httpd.conf, conf.d, etc. (outside any <Directory> containers) :
RewriteCond %{HTTP_HOST} ^www\.domainA\.com [NC]
RewriteRule ^/foo/bar\.html$ http://www.domainB.com/foo/bar.html [R=permanent,L]
RewriteCond %{HTTP_HOST} ^www\.domainA\.com [NC]
RewriteRule [b]^fo[/b]o/bar\.html$ http://www.domainB.com/foo/bar.html [R=301,L]
Note also that this only redirects that URL-path if requested from the "www" subdomain; Requests for domainA.com/foo/bar.html will not be redirected. You could change the RewriteCond pattern to do both:
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com [NC]
RewriteCond %{HTTP_HOST} ^([^.]+\.)*domainA\.com [NC]
Jim