0

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.)

4

1 回答 1

1

我这样做的方法是为所有别名域创建一个新的 vhost 容器,并将它们指向我网站中的一个新目录。

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

在新目录中,我添加了一个 mod_rewrite 脚本来将所有请求重定向到主页

  • www.example.com

Options +FollowSymLinks

<IfModule mod_rewrite.c>

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

</IfModule>
于 2010-01-26T15:45:48.433 回答