2011-01-14 66 views
1

我想在我的本地开发机器上实现一个新的重写规则。我已经制定了13条规则,并且一切正常(甚至在撰写本文时)。但是,由于某种原因,最新的一个投掷我500内部服务器错误。Apache ReWriteEngine抛出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 

在剧本我想重定向到查看/ index.php的东西= $ 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规则及其相应的着陆页都以完全相同的方式设置。

这是在吹我的脑海。任何帮助,请!!

在从马克BI建议开启RewriteLog,以及与此想出了:

:: 1 - - [13 /月/ 2011:23:00:09 --0500] [本地主机/ SID#807df8 (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](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)[per-dir /用户/ 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 /]内部重定向与/stuff/public_html/vault/mystuff/view/index.php [内部重定向]

它看起来像它试图发送参数?stuff = index.php,但我不明白如何这是可能的。有任何想法吗?

回答

2

是不是重写规则匹配它的目的地?它会循环。您需要添加在最后说停止处理重写规则的标志:

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

+1

你说得对,我没有注意到。我将目的地的名称更改为index2.php,更新了.htaccess,重新启动了服务器,并且仍然抛出500 – 2011-01-14 04:07:26

+0

因为它仍然匹配。你添加了[L]吗?或者移动索引mystuff/view/ – 2011-01-14 04:10:49

5

打开改写记录:

RewriteLog /path/to/rewritelog.file 
RewriteLogLevel 9 
在httpd.conf

。这基本上会记录重写引擎所做的一切,并且您将能够看到URL在系统中的确切路径,并且很可能是为什么它正在做一个看起来是无限循环的东西

0

我不知道有它这条道路的要求:/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] 
相关问题