2015-06-28 282 views
1

我剛剛從CentOS dedi移動到Ubuntu VPS。該網站是自定義編碼的PHP。重定向循環和.htaccess

前端工作正常(包括重寫規則)。管理後臺我不能重寫規則工作...

第一個錯誤:

H00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 

然後使用調試級別後:

AH00122: redirected from r->uri = /admin/index.php 

我的htaccess的相關位是:

# mod_rewrite set: 

Options +Includes 

RewriteEngine on 

# Administration 
RewriteCond %{REQUEST_URI} ^(/+)admin/(.*)$ 
RewriteRule (.*) %{DOCUMENT_ROOT}/admin/index.php [L,QSA] 

# Rewrite orther 
RewriteCond %{REQUEST_URI} !^(/+)index.php(.*)$ 
RewriteCond %{REQUEST_URI} !^(/+)syscmd.php$ 
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php?page=$1 [L,QSA] 

# If Rewriting Failure, Show error message (Internal backup) 
RewriteCond %{REQUEST_URI} !^(/+)index.php$ 
RewriteCond %{REQUEST_URI} !^(/+)syscmd.php$ 
RewriteRule (.*) \1 [F] 

這在CentOS上也可以正常工作。

任何想法?我已經嘗試添加以下作爲第一個條件:

RewriteCond %{REQUEST_URI} !/admin/ [NC] 

這完全停止它重寫/管理。

感謝

回答

1

您的規則不正確顯示爲%{DOCUMENT_ROOT}代表文件系統路徑,它不應該在目標URL中使用。

嘗試下列規則:

Options +Includes +FollowSymLinks 
DirectoryIndex index.php 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^- [L] 

# Administration 
RewriteRule ^admin/(.*)$ admin/index.php [L,NC] 

# Rewrite other 
RewriteCond %{THE_REQUEST} !/syscmd\.php [NC] 
RewriteRule ^(.+)$ index.php?page=$1 [L,QSA] 
+0

謝謝! #Administration下的第一部分工作,我能夠訪問/管理區罰款。但是「#Rewrite other」下的變化打破了前端。基本上我可以使用/index.php加載主頁,並且所有其他內部頁面都可以使用,但是如果我嘗試在沒有index.php的情況下加載主頁(即www.domain.com),那麼它會出現403禁止的錯誤,所以我只是將這一部分恢復到原來的狀態。當然樂於嘗試任何你可能認爲應該起作用的其他改變。再次感謝! – Matt

+1

好的,現在檢查我的更新規則。 – anubhava

+1

工作,謝謝! – Matt