为什么这个 RewriteRule 被破坏了?

发布于 2024-09-24 12:54:36 字数 519 浏览 0 评论 0原文

好吧,伙计们,我很茫然。

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^(.*)$ poker/$1 [L]

向我抛出 500 错误。如果我删除重定向并手动转到 /poker/ ,它就可以工作。如果我使用这个:

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^$ poker/ [L]

显示首页(但不显示 css,因为显然 / 之后的任何内容都不会重定向。

什么可能导致此 (.*) 中断?

在此规则之前就是这样删除 www:

RewriteCond %{HTTP_HOST} ^www\.([a-z-]+)\.([a-z]{2,3})
RewriteRule ^(.*)$ http://%1.%2/$1 [R=301,L]

之后就没有什么可以干扰的了。

Ok folks, I'm at a loss.

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^(.*)$ poker/$1 [L]

Throws me a 500 error. If I remove the redirect and go to /poker/ manually it works. If I use this:

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^$ poker/ [L]

The front page is shown (but the css not, because obviously anything after the / is not redirected.

What could cause this (.*) to break?

Before this rule is just this to remove www:

RewriteCond %{HTTP_HOST} ^www\.([a-z-]+)\.([a-z]{2,3})
RewriteRule ^(.*)$ http://%1.%2/$1 [R=301,L]

After it is nothing that could interfere.

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

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

发布评论

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

评论(1

怎言笑 2024-10-01 12:54:36

太容易了。

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^(.*)$ poker/$1 [L]

给出无限循环。我只需要添加:(

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteCond %{REQUEST_URI} !^/poker
RewriteRule ^(.*)$ poker/$1 [L]

或者正如我刚刚发现的那样,在 /poker/ 目录中仅使用 RewriteEngine On 创建一个空的 .htaccess 也可以达到目的)。

It was so easy.

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteRule ^(.*)$ poker/$1 [L]

Gives an infinite loop. I just had to add:

RewriteCond %{HTTP_HOST} ^domain.nl$
RewriteCond %{REQUEST_URI} !^/poker
RewriteRule ^(.*)$ poker/$1 [L]

(or as I just found out, creating an empty .htaccess with just RewriteEngine On in the /poker/ dir did the trick as well).

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