2014-01-30 40 views
2

我已經成功安裝了CI的根目錄了很多次,但現在我已經被迫在https://mydomain.com/mvc笨2.1.4安裝在子目錄

存在着一個控制器「登錄」一舉安裝CI「指數「

.htaccess文件看起來像:

Options +FollowSymLinks 
RewriteEngine on 
RewriteBase /mvc 
RewriteRule ^(.*)$ index.php?/$1 [L] 

在配置/ config.php文件

$config['base_url'] = 'https://mydomain.com/mvc/'; 
$config['index_page'] = ''; 

我的路線是這樣的:

$route['default_controller'] = "login"; 
$route['login'] = "login/index"; 
$route['404_override'] = ''; 

mod_rewrite的啓用
https://mydomain.com/mvc給出了404
https://mydomain.com/mvc/login給出了404
我怎麼錯過?

回答

1

什麼是你的託管?如果是hostgator,則需要添加用戶。

試試這個

RewriteEngine On 
RewriteBase /mvc 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /mvc/index.php/$1 [L] 

,如果你的主機是你需要添加你的名字用戶HostGator的,例如

RewriteEngine On 
RewriteBase /~<name_user>/%{HTTP_HOST} <or> <your folder> 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /~<name_user>/%{HTTP_HOST} <or> <your folder>/index.php/$1 [L] 
+0

託管公司是softlayer.com – pigfox

+0

我也試過這個,同樣的問題,404。 – pigfox

+0

嘗試檢查你的mod_rewrite是否活動,你可以閱讀如何:http://stackoverflow.com/questions/9021425/how檢查是否已在mod-rewrite-is-enabled- – vljc2004

0

試試這個

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /mvc/index.php?/$1 [L] 
+0

我曾嘗試過這個,同樣的問題,404。 – pigfox

1

試試這個 設置你默認基地子目錄的網址

$配置[ 'BASE_URL'] = 「http://www.example.com/subdir/

打開config.php文件,並做以下內容替換

$config['index_page'] = "index.php" 

$config['index_page'] = "" 

在某些情況下,uri_protocol默認設置不好好工作。所以你剛纔通過

$config['uri_protocol'] = "REQUEST_URI" 

的.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

此代碼運行的所有子目錄替換

$config['uri_protocol'] ="AUTO" 

。希望對你有幫助!。