简体   繁体   English

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

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

I'm trying to implement a new ReWrite rule on my local dev machine. 我正在尝试在本地开发机器上实施新的ReWrite规则。 I have 13 rules set up already, and all work fine (even as of this writing). 我已经设置了13条规则,并且一切正常(即使在撰写本文时)。 However, for some reason the newest one is throwing me 500 Internal Server Errors. 但是,由于某种原因,最新的消息会抛出500个内部服务器错误。

The ReWrite rule is: 重写规则是:

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

Checked my apache logs and got this: 检查了我的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

On the script I am trying to redirect to view/index.php?stuff=$1, there is nothing that even remotely resembles a redirect of any kind. 在脚本中,我尝试将其重定向到view / index.php?stuff = $ 1,没有什么比远程任何形式的重定向更像。 I do have a very, very basic session verifier being called at the top of the landing script, which is as follows: 我确实在登录脚本的顶部调用了一个非常非常基本的会话验证程序,如下所示:

//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();
 }

However, when I access the page directly, it acts as it should, and there is no redirect. 但是,当我直接访问该页面时,它会按应有的方式工作,并且没有重定向。 All of my other ReWrite rules and their corresponding landing pages are set up the exact same way. 我所有其他的ReWrite规则及其对应的登录页面均以完全相同的方式设置。

This is blowing my mind. 这真让我震惊。 Any help, PLEASE!? 有什么帮助吗?

On suggestion from Marc BI turned on RewriteLog, and came up with this: 根据Marc BI的建议,打开了RewriteLog,并提出了以下建议:

::1 - - [13/Jan/2011:23:00:09 --0500] [localhost/sid#807df8][rid#941b38/initial/redir#10] (2) [per-dir /Users/stepheng/Development/] rewrite stuff/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](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/vault/mystuff/view/index.php?stuff=index.php -> uri=/stuff/public_html/vault/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)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) [per-dir /Users/stepheng/Development/] applying pattern 'stuff/public_html/vault/mystuff/view/(.*)/' to 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](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) [per-dir /Users/stepheng/Development/] internal redirect with /stuff/public_html/vault/mystuff/view/index.php [INTERNAL REDIRECT] :: 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 [内部重定向]

It looks like it's trying to send the argument ?stuff=index.php, but I don't see how that's possible. 似乎正在尝试发送参数?stuff = index.php,但我不知道这是怎么可能的。 Any ideas? 有任何想法吗?

Turn on rewrite logging: 打开重写日志记录:

 RewriteLog /path/to/rewritelog.file
 RewriteLogLevel 9

in your httpd.conf. 在您的httpd.conf中。 That'll basically record EVERYTHING the rewrite engine does, and you'll be able to see the exact path a URL took through the system, and most likely why it's doing what looks to be an infinite loop 这基本上可以记录重写引擎所做的所有事情,您将能够看到URL通过系统的确切路径,以及很有可能为什么它会执行无限循环

Doesn't that rewrite rule match it's destination? 那个重写规则不匹配它的目的地吗? It's going to loop. 它会循环。 You need to add the flags that say stop processing rewrite rules at the end: 您需要在末尾添加表示停止处理重写规则的标志:

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

I'm not sure about the request having this path in it: /stuff/public_html/vault/mystuff/view - where does your document root point to? 我不确定请求中是否包含以下路径: /stuff/public_html/vault/mystuff/view您的文档根目录指向何处?

Could you post your full apache? 您能发布完整的Apache吗?

Meantime, try this - it stops redirects if the system matches an existing file or directory, so you should only redirect the once: 同时,尝试此操作-如果系统与现有文件或目录匹配,它将停止重定向,因此您只应重定向一次:

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