繁体   English   中英

Apache ReWriteEngine因太多内部重定向而引发500 Internal Server Error…为什么?

[英]Apache ReWriteEngine throwing 500 Internal Server Error for too many internal redirects… why?

我正在尝试在本地开发机器上实施新的ReWrite规则。 我已经设置了13条规则,并且一切正常(即使在撰写本文时)。 但是,由于某种原因,最新的消息会抛出500个内部服务器错误。

重写规则是:

RewriteRule stuff/public_html/vault/mystuff/view/(.*) /stuff/public_html/vault/mystuff/view/index.php?stuff=$1

RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1

检查了我的Apache日志,并得到了:

[Thu Jan 13 22:07:43 2011] [error] [client ::1] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary., referer: http://localhost:8888/stuff/public_html/vault/mystuff/all/index.php?curr=7

在脚本中,我尝试将其重定向到view / index.php?stuff = $ 1,没有什么比远程任何形式的重定向更像。 我确实在登录脚本的顶部调用了一个非常非常基本的会话验证程序,如下所示:

//Start session
 session_start();

 //Check whether the session variable SESS_MEMBER_ID is present or not
 if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
  header("location: ".$root_http."");
  exit();
 }

但是,当我直接访问该页面时,它会按应有的方式工作,并且没有重定向。 我所有其他的ReWrite规则及其对应的登录页面均以完全相同的方式设置。

这真让我震惊。 有什么帮助吗?

根据Marc BI的建议,打开了RewriteLog,并提出了以下建议:

:: 1--[13 / Jan / 2011:23:00:09 --0500] [localhost / sid#807df8] [rid#941b38 / initial / redir#10](2)[每个目录/用户/ stepheng / Development /]重写东东/public_html/vault/mystuff/view/index.php-> /stuff/public_html/vault/mystuff/view/index.php?stuff=index.php

:: 1--[13 / Jan / 2011:23:00:09 --0500] [localhost / sid#807df8] [rid#941b38 / initial / redir#10](3)split uri = / stuff / public_html /保险库文件/mystuff/view/index.php?stuff=index.php-> uri = / stuff / public_html /保险库文件/mystuff/view/index.php,args = stuff = index.php

:: 1--[13 / Jan / 2011:23:00:09 --0500] [localhost / sid#807df8] [rid#941b38 / initial / redir#10](3)[每个目录/用户/ stepheng / Development /]将模式'stuff / public_html / vault / mystuff / view /(.*)/'应用于uri'/stuff/public_html/vault/mystuff/view/index.php'

:: 1--[13 / Jan / 2011:23:00:09 --0500] [localhost / sid#807df8] [rid#941b38 / initial / redir#10](1)[每个目录/用户/ stepheng / Development /]内部重定向,使用/stuff/public_html/vault/mystuff/view/index.php [内部重定向]

似乎正在尝试发送参数?stuff = index.php,但我不知道这是怎么可能的。 有任何想法吗?

打开重写日志记录:

 RewriteLog /path/to/rewritelog.file
 RewriteLogLevel 9

在您的httpd.conf中。 这基本上可以记录重写引擎所做的所有事情,您将能够看到URL通过系统的确切路径,以及很有可能为什么它会执行无限循环

那个重写规则不匹配它的目的地吗? 它会循环。 您需要在末尾添加表示停止处理重写规则的标志:

RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1 [L]

我不确定请求中是否包含以下路径: /stuff/public_html/vault/mystuff/view您的文档根目录指向何处?

您能发布完整的Apache吗?

同时,尝试此操作-如果系统与现有文件或目录匹配,它将停止重定向,因此您只应重定向一次:

RewriteEngine on

RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1 [QSA,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM