2017-01-03 67 views
1

我承載了一個網站作爲"http://www.sitename.com/projectfoldername/"這樣的子文件夾。 在這裏它只顯示主頁,當點擊任何菜單時,它顯示404錯誤,所以我通過編寫index.php之前控制器名稱現在URL已更改從這裏: "http://www.sitename.com/projectfoldername/controller-name/function-name"到這個:"http://www.sitename.com/projectfoldername/index.php/controller-name/function-name"然後它顯示了網頁,但只能在本地工作...htaccess在服務器上無法正常工作

我htaccess文件

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

的config.php

$config['base_url'] = 'http://www.sitename.com/projectfoldername/'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

回答

1

如果使用Apache Web服務器,活躍你的mod_rewrite

在Ubuntu:

sudo a2enmod rewrite 

在Window:

打開你的httpd.conf並找到行

#LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘#’ 
0

使用RewriteBase /projectfoldername.htaccess文件像這樣:在.htaccess

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

不工作,不改變 –

0

嘗試添加以下的,它可以幫助你。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 
+0

不工作,不改變 –

相關問題