2015-06-28 397 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