1
votes

I want to redirect/forward several hundred domains each one of them to a special page on my main website ... for example, let's say I own business.com .. I want when someone try to visit any page on www.business.com will be redirected to the page www.mywebsite.com/business.com on my website.

As I said I want to redirect/forward several hundred and they go up and down in count all the time so it will be impossible to do it one by one. I want a solution more like how parking companies handle domains by pointing the domains to a DNS Servers like ns1.myowndns.com & ns2.myowndns.com and take it from there.

PS: I own a VPS using WHM Panel.

Looking forward to your replies.

1
use php to write contents to a .htaccess, or write a php script to interpret the domain and redirect accordingly.gorelative

1 Answers

2
votes
  • Set up virtual hosting on your server
  • Point the A record for all of your domains to your server
  • Set up an explicit virtual host for (from the question) www.mywebsite.com
  • Set up a default host to handle all requests to unrecognised domains.
  • Put this .htaccess in the root of the default host:

.htaccess

RewriteEngine On
RewriteRule ^.*$ http://www.mywebsite.com/%{HTTP_HOST} [L,R=302]

You could also place those lines in <VirtualHost> section for the default host if you want to keep your file system free of directories containing just a .htaccess