![]() |
mapping multiple domains into the filespace of a single domain
There is simply no reason to expose the subdirectories, *and* it makes the URLs ugly, so don't do a redirect. Use an internal rewrite instead. It's very simple code, and nothing to be concerned with SEO-wise.
Options +FollowSymLinks RewriteEngine on # RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com [OR] RewriteCond %{HTTP_HOST} ^$ RewriteCond $1!^domainA/ RewriteRule (.*) /domainA/$1 [L] # RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com RewriteCond $1!^domainB/ RewriteRule (.*) /domainB/$1 [L] Each domain is rewritten to its own subdirectory, unless the request has already been rewritten to the subdirectory (mod_rewrite in .htaccess appears to be recursive, so testing for this case is necessary if the code is in .htaccess, but not if it's in httpd.conf). Search engines and visitors will be entirely unaware that two sites are hosted under the same account, unless they investigate the domain registrations and DNS records; the rewrite process itself is entirely transparent. You can move everything, including a robots.txt file for each domain, into its own subdirectory; the only file needed in the home directory is this .htaccess file. True HTTP/1.0 clients do not provide a host header. For this reason, a default rewrite (to domainA) is provided above. While many clients advertise that they are HTTP/1.0, most have been modified to send the host header, since otherwise they cannot access any sites that are hosted on name-based virtual servers (Name-based servers depend on the HTTP host header to figure out which of the many sites at the same IP address to serve). Since you've set up the DNS, the only concern is whether your server is set up to accept both domain names and send requests for them to your document root ('home' directory). If that's taken care of, then adding the above rules to your existing .htaccess file should do what you need. |
| All times are GMT +8. The time now is 06:28 PM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.