.htaccess 将子域重定向到主站点 - 没有例外

发布于 2024-09-28 15:54:24 字数 406 浏览 3 评论 0原文

我正在尝试将 subdomain.example.com 的所有请求重定向到 www.example.com

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

似乎会导致 500 内部服务器错误,

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] 

所以我的问题是为什么这些失败以及如何修复它?

I'm trying to redirect all requests for subdomain.example.com to www.example.com

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Seems to cause a 500 internal server error as does

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] 

So my question is why are these failing and how do I fix it?

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

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

发布评论

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

评论(1

白云悠悠 2024-10-05 15:54:24

在前两行之后添加:

RewriteCond %{http_host} ^.domain.com
RewriteRule ^(.*) http://domain.com/$1 [R=301]

After your first two lines, add:

RewriteCond %{http_host} ^.domain.com
RewriteRule ^(.*) http://domain.com/$1 [R=301]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文