htaccess 仅重写子域

发布于 2025-01-04 11:27:46 字数 252 浏览 3 评论 0原文

我正在尝试为子域进行重定向,但我无法弄清楚。 这就是我现在所拥有的:

RewriteCond %{HTTP_HOST} ^(mysubdomain).myhost.com$ [NC]
RewriteRule (.*) http://www.myhost.com/folder/index.html [R=301,L]

但是当我在浏览器中转到子域地址时,没有重定向。

我只需要一个特定的子域。 我哪里出错了?

I am trying to make a redirect for a subdomain but i can't figure it out.
This what I have now:

RewriteCond %{HTTP_HOST} ^(mysubdomain).myhost.com$ [NC]
RewriteRule (.*) http://www.myhost.com/folder/index.html [R=301,L]

But when I go to the subdomain address in my browser, there's no redirect.

I need this for only one specific subdomain.
Where am I going wrong?

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

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

发布评论

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

评论(2

原野 2025-01-11 11:27:46

应该是:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC] 
RewriteRule ^.*$ http://www.domain.com/folder/ [R=301,L]

Should be:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC] 
RewriteRule ^.*$ http://www.domain.com/folder/ [R=301,L]
梦开始←不甜 2025-01-11 11:27:46

尝试一下这一点,因为您只需要来自一个域的它。 () 在这两种情况下都是毫无意义的。特别是在第二行,您没有将旧 URL 传递给新 URL。

RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC]
RewriteRule ^.*$ http://www.myhost.com/folder/index.html [R=301,L]

Try this, since you only need it from one domain. The () are pointless in both cases. Especially on the 2nd line where you aren't passing the old URL to the new URL.

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