2014-01-21 36 views
2

我的項目在我的服務器上的本地成功,但不工作的工作,我有一個Linux服務器在HostGator的如何使用codeigniter中的linux服務器上的.htaccess從url中刪除index.php?

默認控制器是託管工作正常,但例如:

example.com/contact-us不工作會重定向到服務器的404頁找不到網頁,但example.com/index.php/contact-us工作

我的.htaccess代碼:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

配置:

$config['base_url']  = 'http://linksture:2000/websitebusinessforsale.com/project'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

我不知道什麼問題,預先感謝您的回覆

+0

可能重複http://stackoverflow.com/questions/15217862/codeigniter-application-works-on-hostgator-but-not-another-web-host – tomexsans

+0

@tomexsans不適合我... – darshan

回答

0

試試這個

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
+0

不工作... :(相同的問題.. – darshan

0

這很可能是你的代碼是一個文件夾內從apache根。如果是這樣的話,你需要寫

/project/index.php/$0 

因此,如果您上傳所有的代碼到的/ var/WWW/myproject的,然後使用

/myproject/index.php/$0 
+0

我不能理解你寫什麼代替/項目? – darshan

0

我知道也許你找到一個解決方案這個問題, 問題出在Apache配置中。

首先,找到配置文件,(在我的情況,我用Linux Mint的) 配置文件應該是下/etc/apache2/sites-available/

繼續編輯default.conf文件(這取決於你的機器上,我在我的機器它通過使用此命令命名000-default.conf) 編輯文件sudo gedit 000-default.conf

將這個命令虛標籤外

<Directory /var/www/html> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
</Directory> 

保存並使用sudo service apache2 restart

重新啓動您的apache因此,您必須在您的機器上找到apache配置文件,然後執行相同的步驟。

相關問題