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

发布于 2024-08-19 05:07:08 字数 388 浏览 6 评论 0原文

一家外部公司拥有我托管的网站的多个域的名称服务器。

我托管该站点,并使用域名和域别名设置了虚拟主机:

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

外部域还需要重定向到该站点:

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

我必须在我的虚拟主机容器文件中添加什么,才能将某个域和另一个域的所有请求重定向到主 www.example.com

(我计划管理 www 和非 www 使用 mod_rewrite 请求。)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拧巴小姐 2024-08-26 05:07:08

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

  • 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文