开发者

htaccess internal server error

When I goto http://example.com/not-here I g开发者_JAVA技巧et 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


I should have in the .htaccess the following:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !rewrited
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /$1.php?rewrited=1 [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


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.


internal server error is being caused by infinite looping of your RewriteRule.

Just change your RewriteRule to this:

RewriteRule ^(.+)(?<!\.php)$ /$1.php [L,NC]

Negative lookbehind (?<!\.php) will prevent more than one internal redirections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜