简体   繁体   English

DNS Apache重定向以获取其他地方持有的域名

[英]DNS Apache redirect for domain names held elsewhere

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: 我托管该网站,并使用domainName和domainAlias进行了以下虚拟主机设置:

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

The external domains also need to redirect to the site: 外部域还需要重定向到站点:

  • www.somedomain.com www.somedomain.com
  • www.anotherdomain.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 我必须添加到我的vhost容器文件中,才能将对somedomain和anotherdomain的所有请求重定向到主www.example.com

(I plan to manage the www and non www requests with mod_rewrite.) (我计划使用mod_rewrite管理www和非www请求。)

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. 我这样做的方法是为所有别名域创建一个新的vhost容器,并将它们指向我的网站中的新目录。

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

In the new directory I added a mod_rewrite script to redirect ALL the requests the main page 在新目录中,我添加了一个mod_rewrite脚本来重定向所有请求的主页

  • www.example.com www.example.com

Options +FollowSymLinks

<IfModule mod_rewrite.c>

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

</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM