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 (http://maindomain.net)
    • number1domain (http://www.number1domain.com)
    • number2domain (http://number2domain.org)
    • number3domain (http://number3domain.net)

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 "www.maindomain.net/number2domain" OR "http://number2domain.maindomain.net" they should get ONLY "http://number2domain.org". If they happen to type in "www.maindomain.net" they should get ONLY http://maindomain.net.

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:

Code:
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:

Code:
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:

Code:
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 http://number2domain.org, which is good. But the problem remains that calls to www.maindomain.net/number2domain get redirected to http://number2domain.org/number2domain, 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