htaccess 内部服务器错误
当我转到 http://example.com/not-here 时,我收到内部服务器错误而不是404,这是我的 htaccess 文件(它删除了扩展名,因此 abc.php 可以作为 example.com/abc 而不是 example.com/abc.php 访问):
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /$1.php [L,QSA]
DirectoryIndex login.php index.php
ErrorDocument 403 /error.php?type=403
ErrorDocument 404 /error.php?type=404
ErrorDocument 500 /error.php?type=500
它可能非常简单,但我看不到它,任何帮助都是受重视的
When I goto http://example.com/not-here I get an internal server error instead of an 404, here is my htaccess file (it removes the extension so abc.php can be accessed as example.com/abc instead of example.com/abc.php):
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /$1.php [L,QSA]
DirectoryIndex login.php index.php
ErrorDocument 403 /error.php?type=403
ErrorDocument 404 /error.php?type=404
ErrorDocument 500 /error.php?type=500
Its proberly something really simple but I cannot see it, any help is appriciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我应该在 .htaccess 中有以下内容:
I should have in the .htaccess the following:
当我遇到这个问题时,我所做的就是注释掉行。注释掉重写部分,看看是否有效。要注释掉代码,只需将 # 作为第一个字符即可。这一切都是为了将代码范围缩小到罪魁祸首。
What I do when I run into this is comment out lines. Comment out the rewrite section and see if that works. To comment out code just put a # as the first character. It's all about narrowing the code down to the culprit line.
内部服务器错误
是由 RewriteRule 的无限循环引起的。只需将您的 RewriteRule 更改为:
Negative Lookbehind (? 将阻止多个内部重定向。
internal server error
is being caused by infinite looping of your RewriteRule.Just change your RewriteRule to this:
Negative lookbehind (?<!\.php)
will prevent more than one internal redirections.