Mod Rewrite 500错误更正

编程入门 行业动态 更新时间:2024-10-24 04:48:22
本文介绍了Mod Rewrite 500错误更正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用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错误更正

本文发布于:2023-11-01 12:28:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549331.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Mod   Rewrite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!