Three domains all point to one IP address on Apache 2.2.X. The goal is to have any page requested from (not the actual names) alpha.com (or www.alpha.com), bravo.com (or www.bravo.com), or charlie.com, be served as pages from www.charlie.com because www.charlie.com is the parent company's name. The other domains are perhaps "aliases" (domains named for company subdivisions--is "alias" the right term?). Does it probably serve the company best to serve all page requests as main company name domain (www.charlie.com). Comment on this approach?
The problem I've run into is I am unsure of my RewriteCond and RewriteRule construction. We're having sporadic problems with page requests on bravo.com; to isolate where the problem lies, I need feedback on this part of my .htaccess. Here is the code:
- Code: Select all
Options +FollowSymlinks +Includes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} www.alpha\.com [NC]
RewriteRule ^(.*)$ http://www.charlie.com/$1 [R=301]
RewriteCond %{HTTP_HOST} ^alpha\.com [NC]
RewriteRule ^(.*)$ http://www.charlie.com/$1 [R=301]
RewriteCond %{HTTP_HOST} www.bravo\.com [NC]
RewriteRule ^(.*)$ http://www.charlie.com/$1 [R=301]
RewriteCond %{HTTP_HOST} ^bravo\.com [NC]
RewriteRule ^(.*)$ http://www.charlie.com/$1 [R=301]
RewriteCond %{HTTP_HOST} ^charlie\.com [NC]
RewriteRule ^(.*)$ http://www.charlie.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[^/]*/index\.html [NC]
RewriteRule . / [R=301,L]
This is what I cobbled together from research here and other places. Is there a more elegant solution? Do I need to identify alpha/bravo/charlie individually in this way or can same result be achieved using wildcards? Is there anything here that would cause requests on bravo.com or www.bravo.com to return error pages (domain not found or is having problems)?
Thank you kindly for your review.