2013-01-22 80 views
0

我剛剛從我的本地服務器(XAMPP)上傳了我的網站。它在本地工作,但出於某種原因,重寫將index.php添加到我的SEF URL中並不適用於我的公共服務器。這是我有現在:Codeigniter:重寫刪除index.php不起作用

# Avoid listing directory 
Options -Indexes 

<IfModule mod_rewrite.c> 
Options +FollowSymlinks 
RewriteEngine on 

# manage language segment 
RewriteRule ^(es|en)/(.*) $2?lang=$1 [L] 

# code that allows to get rid of index.php from URL 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

</IfModule> 

這些網址的工作:

www.example.com

www.example.com/index.php/aboutme

雖然這樣的URL會生成一個500錯誤

www.example.com/aboutme

這裏的條件另一個組合而治我試圖解決的index.php去除:

RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml) 
RewriteRule ^(.*)$ index.php/$1 [L] 

但它的任何URL生成一個500錯誤,而不指數.php,包括根網址www.example.com

你能幫我解決這個問題嗎?

回答

2

你的RewriteRule似乎有一個錯字。

試試這個:

RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

它爲我們提供了代碼點火器。唯一的區別是index.php的斜線與你的第二個例子相比。

+0

'RewriteBase /'也可以。 – Brendan

+0

確實如此,但是來自[用戶手冊](http://ellislab.com/codeigniter/user-guide/general/urls.html)。 – bms

+0

它的工作原理!非常感謝!如何在沒有斜槓的本地服務器上工作? –