2011-01-14 32 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] 
相關問題