I keep putting off this problem and it’s been several years now, so I need to fix it. I am now being hosted on a VPS and have the main domain and several other domains as sub-folders. The organization is thus:
- public_html ([noparse]http://maindomain.net[/noparse])
[LIST] - number1domain ([noparse]http://www.number1domain.com[/noparse])
- number2domain ([noparse]http://number2domain.org[/noparse])
- number3domain ([noparse]http://number3domain.net[/noparse])
[/LIST]
Each one of those domains should appear to be stand-alone domains, with no reference to the main domain (unless it IS the main domain). In other words, if someone types in their browser “[noparse]www.maindomain.net/number2domain[/noparse]” OR “[noparse]http://number2domain.maindomain.net[/noparse]” they should get ONLY “[noparse]http://number2domain.org[/noparse]”. If they happen to type in “[noparse]www.maindomain.net[/noparse]” they should get ONLY [noparse]http://maindomain.net[/noparse].
I have tried a number of ways in htaccess and today I found the tutorial frequently linked to and it has helped some, but I still have issues I hope someone can help with. Here is the contents of htaccess in maindomain.net:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^maindomain\\.net$ [NC]
RewriteRule .? http://maindomain.net%{REQUEST_URI} [R=301,L]
This is the contents of htaccess in number1domain.com:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\\.number1domain\\.com$ [NC]
RewriteRule .? http://www.number1domain.com%{REQUEST_URI} [R=301,L]
And this is the contents of htaccess in number2domain.org:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^number2domain\\.org$ [NC]
RewriteRule .? http://number2domain.org%{REQUEST_URI} [R=301,L]
I actually have about 10 domains and they are all set up the same way. Yes, I did run the tests and the server is set up properly. But I am making some kind of mistake as described below.
Using number2domain.org as an example, this causes all calls to number2domain.maindomain.net to be redirected to [noparse]http://number2domain.org[/noparse], which is good. But the problem remains that calls to [noparse]www.maindomain.net/number2domain[/noparse] get redirected to [B][noparse]http://number2domain.org/number2domain[/noparse][/B], which doesn’t exist and causes a 404.
Any help from those who understand htaccess and mod_rewrite much better than I would be appreciated. I appreciate very much the efforts that went into that tutorial, but apparently, I am missing something - maybe parking on a dead brain cell.
Thanks,
Jim