.htaccess无法处理codeigniter子域名&目录安装

时间:2012-07-08 15:59:54

标签: .htaccess codeigniter mod-rewrite

我正在尝试在同样位于子域的目录下安装CI。所以我的基本网址看起来像http://subdomain.domain.com/ci/

以下htaccess在域的根目录下工作正常但在目录上没有,浏览器说有一个重定向循环错误。

这是我的代码:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^sub\.domain\.com/ci/$
RewriteRule ^(.*)$ http://sub.domain.com/ci/$1 [L,R=301]

RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /index.php?/$1 [L]

我不熟悉mod重写,任何帮助将不胜感激!谢谢!

1 个答案:

答案 0 :(得分:1)

在您的/ ci目录中,您的htaccess应如下所示

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f # this means if the requested file name doesnt exist 
RewriteCond %{REQUEST_FILENAME} !-d # this means if the requested directory doesnt exist 
RewriteRule ^(.*)$ index.php [L]

基于您的上述评论应该足够