2014-11-17 64 views
1

我之前使用过其他主机,一切正常,但现在我已将其更改为新的。在新主机上安装apache 2.4。mod_rewrite在apache 2.4上工作不正确

我的下一个规则:

<IfModule mod_rewrite.c> 
     RewriteEngine on 
     RewriteBase/
     RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] 
     RewriteRule ^/?(.*) http://%1/$1 [L,R=permanent] 

     RewriteRule manage/ajax/(.*?)$ manage/ajax/index.php [QSA,L] 
     RewriteRule manage/json/(.*?)$ manage/json/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule ckfinder/(.*?)$ ckfinder/index.html [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule manage/(.*?)/$ manage/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule ajax/(.+?) ajax/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule api/(.*?) /api/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule (.*) index.php 
</IfModule> 

当我尝试访问例如/管理/它告诉我的索引页,但如果我将一些额外的数据添加到路径它会告诉我我需要什么。例如:/manage/some_data - 工作正常。但我想通过/manage/访问正确的目录。

+1

在你的.htaccess – anubhava

+0

感谢的顶部,即固定我的问题只是用'的DirectoryIndex index.php'。 – user2058653

+0

不客气,很高兴帮助。 – anubhava

回答

2

将此规则更改为:

RewriteCond %{REQUEST_URI} !\.(.+)$ 
RwriteRule manage/(.*?)/$ manage/index.php [QSA,L] 

RewriteCond %{REQUEST_URI} !\.(.+)$ 
RwriteRule manage(/.*)?$ manage/index.php [QSA,L] 
+0

同样的结果,没有什么改变。 – user2058653

+0

绝对确定您输入的内容正确吗?正则表达式应该工作。看到这里:http://regex101.com/r/jN1jA8/2 – arco444

+0

我不认为这个问题是在正则表达式,因为我的规则在旧服务器上正常工作。我认为在逻辑上有问题,也许在新的Apache与mod_rewrite更改? – user2058653