2012-07-08 67 views
0

我試圖將CI安裝在同樣位於子域上的目錄下。所以我的基地網址看起來像http://subdomain.domain.com/ci/.htaccess無法在codeigniter子域名和目錄安裝上工作

下面的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] 

我不是很熟練的與國防部重寫,任何幫助,將不勝感激!謝謝!

+0

你需要在你希望在結果更明確一點,應該是足夠您的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] 

你希望你的網址結構看起來像什麼條款。您對%{HTTP_HOST}的使用將成爲最初的問題,因爲這會忽略後面的'/ ci',這可能是您爲什麼會收到重定向循環 – 2012-07-08 16:02:58

+0

我希望我的基本安裝的CodeIgniter位於:http:/ /subdomain.domain.com/ci/index.php 所以我的正常控制器方法看起來像:http://subdomain.domain.com/ci/method/ 您提到%{HTTP_HOST},我應該刪除此徹底?或使用別的東西?這個htaccess代碼不是我的代碼,我現在發現它在一年前或更多。謝謝 – Chris 2012-07-08 16:06:26

+0

但你也希望任何請求'subdomain.domain.com'被轉發到'subdomain.domain.com/ci'? – 2012-07-08 16:07:39

回答

1

裏面你/ CI目錄根據您的上述評論

+0

非常感謝,它看起來是在第一眼看起來。如果一切順利,我將測試一些事情,並將其標記爲答案。欣賞它! – Chris 2012-07-08 16:19:38