views:

26

answers:

1

An external company holds the name servers for several domains for a web site which I host.

I host the site and have a vhost setup with the domainName and domainAlias for:

  • www.example.com
  • admin.example.com

The external domains also need to redirect to the site:

  • www.somedomain.com
  • www.anotherdomain.com

What must I add to my vhost container file to redirect all requests for somedomain and anotherdomain to the main www.example.com

(I plan to manage the www and non www requests with mod_rewrite.)

A: 

The way I did this was to create a new vhost container for all the alias domains and point them to a new directory in my web site.

  • www.somedomain.com
  • www.anotherdomain.com
  • somedomain.com
  • anotherdomain.com

In the new directory I added a mod_rewrite script to redirect ALL the requests the main page

  • www.example.com

Options +FollowSymLinks

<IfModule mod_rewrite.c>

  RewriteEngine on
  RewriteCond %{HTTP_HOST} .
  RewriteRule (.*) http://www.example.com/ [R=301,L]

</IfModule>
Jon Winstanley