2012-07-05 63 views
1

删除我知道这是简单的从一个笨URI与RewriteRule ^(.*)$ index.php/$1 [L]删除的index.php。我的问题是由于我的.htaccess文件中的其他一些规则而发生的。index.php在www后添加。用的.htaccess

我的问题是,当用户进入www.mydomain.com/blog他们将被重定向到mydomain.com/index.php/blog,当有尾随斜线不会发生这种情况; www.mydomain.com/blog/正确地重定向到mydomain.com/blog。我真的不希望index.php在那里。另外一个方面说明的是,理想情况下应该在用户输入的index.php在URL我想他们是没有一个URL。

我现在的.htaccess文件是这样的:

RewriteEngine on 
RewriteBase/

# Protect CI system folders 
RewriteCond %{REQUEST_URI} ^/(application|system)/(.*)$ 
RewriteRule ^(.*)$ index.php/$1 [L] 

# Prevent rewriting URIs that exist: (-d directory -f files) 
RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 

# Remove index.php 
RewriteRule ^(.*)$ index.php/$1 [L] 

# Remove www. 
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC] 
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L] 

# Remove trailing slash 
RewriteRule ^(.+)/$ http://mydomain.com/$1 [R=301,L] 

我是比较新的调整.htaccess文件;请让我知道,如果在有什么,大多数这已经创造了可能进行调整优化,不好的做法,通过等通过谷歌徘徊!

非常感谢。

+0

有你'config.php'到'“”'设置索引文件的价值? – 2012-07-05 18:40:46

+0

是的,配置文件设置正确。 – 2012-07-05 18:53:01

回答

1

你的规则的顺序很重要。尝试将RewriteRule ^(.*)$ index.php/$1 [L]移至底部。请记住,也设置在$config['index_file']application/config/config.php

相关问题