Question

Have searched and viewed many threads, but mostly are about forwarding multiple domains to 1 single site/domain.

What i have now is around 50 domainnames which i have directed to my server ip address. On my server i use Directadmin.

What i would like is to have the most efficient/easiest way to manage these domainnames and have them forward to (different) sites.

So for example, Domain1.com, needs to be forwarded to someotherdomain1.com Domain2.com, needs to be forwarded to someotherdomain2.com Domain3.com, needs to be forwarded to someotherdomain3.com

What would be the easiest way for me to set something like this up?

Thank you in advance

Was it helpful?

Solution

You can use these type of rules:

RewriteBase /

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain1\.com$ [NC]
RewriteRule ^ http://someotherdomain1.com%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain2\.com$ [NC]
RewriteRule ^ http://someotherdomain2.com%{REQUEST_URI} [R=301,L,NE]

Alternatively if you have access to Apache config then you can utilize RewriteMap feature and have just one single rule here like this:

RewriteCond %{HTTP_HOST} ^(?:www\.)?([^.]+)\.com$ [NC]
RewriteRule ^ http://${domainMap:%1}.com%{REQUEST_URI} [R=301,L,NE]

In your Apache config you need to define domainMap as:

RewriteMap domainMap txt://path/to/domain-map.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top