错误 500 或重写规则以获取干净的 URL
在 .htaccess
中使用以下重写规则时,我不断收到 500 内部服务器错误:
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
本质上,我希望 Web 应用程序上有干净的 URL,即 www.example.com/login 的功能与 www.example.com/index.php/login 相同。
此重写规则在 MAMP 本地和不同的 Apache 测试服务器上运行良好,但在客户端基于 1and1.com 的托管上失败。
I keep getting a 500 Internal Server Error when using the following Rewrite rule in my .htaccess
:
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Essentially, I want clean urls on my web application, i.e. www.example.com/login would function the same as www.example.com/index.php/login.
This rewrite rule works fine locally on MAMP and on a different Apache test server, but fails on the client's 1and1.com-based hosting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要防止无限循环。对
index.php
的否定断言是阻止这种情况的一种方法。You need to prevent the infinite loop. A negative assertion on
index.php
is one way to stop this.实际上,我在 CodeIgniter 论坛 中找到了答案。
它并没有修复我的规则,而是采用了稍微不同的方式:
I actually found the answer over at the CodeIgniter forum.
It didn't fix my rule, but instead went at it a slightly different way: