2013-01-22 39 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

它的工作原理!非常感谢!如何在没有斜杠的本地服务器上工作? –