.htaccess 对所有内容都给出递归错误

发布于 2024-09-25 22:41:41 字数 214 浏览 1 评论 0原文

我正在尝试通过index.php 重定向所有流量。

这是我的 .htaccess 文件:

RewriteEngine On

RewriteRule ^(.*)$ /index.php?ref=$1 [NC,L]

我总是收到 HTTP 500 错误,我检查 error.log,发现它是内部递归错误。谁能帮我解决这个问题吗?谢谢。

I am trying to redirect all traffic through index.php.

Here is my .htaccess file:

RewriteEngine On

RewriteRule ^(.*)$ /index.php?ref=$1 [NC,L]

I'm always getting HTTP 500 errors, and I check the error.log and I see that its the internal recursion error. Can anyone help me with this? Thanks.

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

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

发布评论

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

评论(1

何其悲哀 2024-10-02 22:41:41

不完全确定这是否是执行此操作的规范方法,但添加这样的条件将起作用:(

RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php?ref=$1 [QSA]

添加任何查询字符串的 QSA。)

但是,我建议使用附加方法

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

来防止通过索引发送静态资源。 php(除非那确实是您想要的。)

Not entirely sure whether this is the canonical way to do this, but adding a condition like this will work:

RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php?ref=$1 [QSA]

(The QSA to add any query strings.)

However, I would recommend an additional

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

to prevent static resources from being sent through your index.php (unless that is really what you want.)

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