我有一个使用Mod_Rewrite的.htaccess文件,但是如果有人在URL中放入垃圾邮件,就会产生500错误并显示我所有的mod信息,我遇到了问题.我想阻止它生成500错误,或者将该错误转发到其他页面.我已经尝试过了.
I have a .htaccess file that is using Mod_Rewrite but I am running into a problem if someone puts in junk in the URL it generates a 500 error, and displays all my mod information. I would like to either stop it from generating the 500 error or forward that error to a different page. I have tried.
Error Document 500 /index.php...但是它不起作用或重定向.
...but it does not work or redirect.
这是我完整的.htaccess
Here is my full .htaccess
Options -Indexes Options +FollowSymlinks ErrorDocument 500 /index.php RewriteEngine On RewriteRule ^BEARS bears.php?page=bears [NC,L] RewriteCond %{http_host} ^www.domian/login.php [NC] RewriteRule ^(.*)$ www.domian/login.php [R=301,L] RewriteCond %{http_host} ^domian [NC] RewriteRule ^(.*)$ www.domian/$1 [R=301,L] RewriteCond %{http_host} ^domian [NC] RewriteRule ^(.*)$ www.domian/$1 [R=301,L] RewriteCond %{http_host} ^www.domian [NC] RewriteRule ^(.*)$ www.domian/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/DB/(.+)/page/(.+)$ $1.php?DB=$2&page=$3 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/DB/(.+)$ $1.php?DB=$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/(.+)$ $1.php?page=$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ $1.php?page=$1 [L,QSA]也没有人知道从哪里产生500错误.我知道错误文件夹中有错误文档,但是此错误显示此外,尝试使用ErrorDocument处理请求时遇到了500 Internal Server Error错误",我找不到从哪里提取错误.
Also does anyone know where the 500 error is being generated from. I know the error folder has the error documents in there, but this error says "Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request" , and I cannot find where this is pulling from.
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php [Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html此循环在哪里发生?没有看到它.
Where is this loop happening? Not seeing it.
推荐答案要扩展您的答案,更具体地说是以下行:
To expand on your answer, it is more specifically this line:
RewriteRule ^(.+)$ $1.php?page=$1 [L,QSA]不检查文件名是否已经以PHP结尾.
which does not check to see if the filename already ends with PHP.
它循环播放,添加.php.php.php.php直到达到最大值(检查apache/logs/error.log),然后只投放原始页面(恰好存在),所以看起来一切正常.
It loops around, adding .php.php.php.php until the max is reached (check apache/logs/error.log) and then just serves the original page, which happens to be present, so it looks like everything's ok.
要解决此问题,请添加以下内容:
To fix this, add something like this:
RewriteRule ^(.*)\.php$ - [L]如果地址以.php结尾,它将停止([L]).
which stops ([L]) if the address ends with .php.
更多推荐
Mod Rewrite 500错误更正
发布评论