Forum Moderators: phranque
I've been struggling with domain redirects for some time now.
The issue:
Multiple domainnames in one server. Some of these domainnames point to names on another server, others point to folders on the same server.
domain1.com is accessible through 10 domainnames. Not a smart thing to do, I know. So I thought I fixed it a while ago with either:
RewriteCond%{HTTP_HOST}^domain2.com$
RewriteCond%{REQUEST_URI}!^/domain2/
RewriteRule(.*)/domain2/$1
or:
RewriteCond %{HTTP_HOST} ^(www\.)?domain3\.com/
RewriteRule (.*) [otherdomain.com...] [R=301,L]
The homepage from the mainsite isn't accessible through any of the 10 domainnames. However the main site has undergone changes and has a few folders. Those folders are accessible now through all those 10 domainnames. Now some of those other domainnames are ending up in Google pointing to the blog(how did they pick up on it?).
For example:
domain1.com/blog
is also accessible through:
domain2.com/blog
I tried reading up on posts and I've phoned support from my host, they told me to do make a folder where all domainnames point to and add a frame there. That still doesn't prevent domain1.com/blog to be accessible through other domains.
Could any help me? Any help is much appreciated.
Best regards,
Roel
If the additional domain is not hosted here on this server:
1) Redirect URL example.com/<anything> to URL other-example.com/<anything>
That's the trivial case, and I'll assume you're not having any trouble with that.
If the additional domain is hosted in a subdirectory on this server:
1) Redirect direct client requests (only) for URL any-domain.com/example/<anything> to URL example.com/<anything>
2) Redirect URL www.example.com/<anything> to URL example.com/<anything>, or Redirect URL example.com/<anything> to URL www.example.com/<anything>, as you choose.
3) Rewrite URL example.com/<anything> to filepath /example/<anything> if not already done.
Example using "example" as both the add-on domain name and the name of the subdirectory where that domain's files are stored:
# Externally redirect direct client requests (only) for URL <any-domain.com>/example/<anything>
# to URL www.example.com/<anything>
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /example/[^\ ]+\ HTTP/
RewriteRule ^example/(.*)$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect any requested hostname which contains "example.com" but is
# not *exactly* "www.example.com/<anything>" to URL www.example.com/<anything>
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite add-on domain requests to subdirectories
RewriteCond %{HTTP_HOST} ^www\.example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteRule ^(.*)$ /example/$1 [L]
Jim
It's late here, so I'll give it another try tomorrow. I wanted to thank you for your reply first ;)
I tried and tried to get this:
RewriteCond%{HTTP_HOST}^domain2.com$
RewriteCond%{REQUEST_URI}!^/domain2/
RewriteRule(.*)/domain2/$1
to redirect all files and folders to another domain, but it just didn't work for the folders. I tried with adding things like: (.*), but it didn't do the trick. With a clear mind I'll try again tomorrow morning.
See you and thanks again.
RewriteCond%{HTTP_HOST}^domain2.com/(.*)$
RewriteCond%{REQUEST_URI}!^/domain2/
RewriteRule(.*)/domain2/$1
They're telling me it's the mysql-database. I think it's quite unlikely, but I'll await the reply and google a bit more myself.
If necessary I'll just move away those domainnames from the host to make sure this problem just doesn't exist anymore.