TLD 与目录的 Apache 重写/重定向不同

发布于 2024-10-21 01:52:30 字数 514 浏览 3 评论 0原文

我已将网站的内容从一个域迁移到另一个域。我已成功设置 .htaccess 重写,将任何对旧域的请求重定向到新域上的同一位置,使用以下代码工作正常:

RewriteEngine On
rewritecond %{http_host} ^roundeltable.com
rewriteRule ^(.*) http://wheelspin.tv/$1 [R=301,L]

但是,我想更进一步。当有人只是请求旧 TLD (http://roundeltable.com/) 时,我希望他们被重定向到新域 (http://wheelspin.tv/rt) 中的特定页面。如果他们从旧域向任何其他位置发出请求(例如,http://roundeltable.com/about) 我希望它们按照现在的方式发送到新域 (http://wheelspin.tv/about) 中完全相同的位置。

这可能吗?如果是这样,怎么办?

I've migrated the content of a site from one domain to another. I have .htaccess Rewrite set up successfully to redirect any request to the old domain to the same location on the new domain, which is working fine, using the following code:

RewriteEngine On
rewritecond %{http_host} ^roundeltable.com
rewriteRule ^(.*) http://wheelspin.tv/$1 [R=301,L]

However, I want to go a little further. When somebody simply requests the old TLD (http://roundeltable.com/) I want them to be redirected to a specific page within the new domain (http://wheelspin.tv/rt). If they make a request to any other location from the old domain (for example, http://roundeltable.com/about) I want them to be sent to that exact same place at the new domain (http://wheelspin.tv/about) the way they currently are now.

Is this possible? If so, how?

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

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

发布评论

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

评论(1

你没皮卡萌 2024-10-28 01:52:30

所以我找到了这个问题的解决方案,最终由 Media Temple 服务部门的人员提供。以下是 .htaccess 文件中实现此功能所需的完整代码:

RewriteEngine On
RewriteRule ^$ http://wheelspin.tv/rt/ [L]
RewriteRule ^(.*)$ http://wheelspin.tv/$1

显然,请替换您想要重定向到的任何域来代替我的域,但这就是我的示例的解决方案。感谢您的帮助!

如果您想查看我的解决方案的所有详细信息,我在这里:christiaanconover.com/media -寺庙服务岩石/

So I've found the solution to this issue, which ended up being provided by somebody from Media Temple's service department. Here's the entire code required in the .htaccess file to make this work:

RewriteEngine On
RewriteRule ^$ http://wheelspin.tv/rt/ [L]
RewriteRule ^(.*)$ http://wheelspin.tv/$1

Obviously substitute whatever domain you want to redirect to in place of mine, but that's the solution for my example. Thanks for the help!

If you want to see all the details on my solution, I have it here: christiaanconover.com/media-temple-service-rocks/

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