2013-02-28 67 views
0

我使用了一个沉闷的重定向:当用户没有登录的笨的重定向重定向我的index.php不断

redirect('/home/login/'); 

。但它一直重定向我

/index.php/home/login/ 

虽然我有这个在我的.htaccess:

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

这可能会帮助您: http://stackoverflow.com/questions/15017448/how-can-remove-index-php-from- url/15017916#15017916 – 2013-02-28 12:01:50

+0

谢谢。它帮助!它始终没有从配置文件中删除index.php,因为我没有在我的早期项目中使用重定向。你应该发布这个答案,以便我可以投票给你。 – 2013-02-28 12:04:58

回答

0

可能的解决方法1:

化妆的.htaccess

<IfModule mod_rewrite.c> 

    RewriteEngine On 
    RewriteBase /#MY_DIRECTORY# 

    RewriteRule ^(#MY_DEFAULT_CONTROLLER#(/index)?|index(\.php)?)/?$/[L,R=301] 
    RewriteRule ^(.*)/index/?$ $1 [L,R=301] 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.+)/$ $1 [L,R=301] 

    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php/$1 [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 

</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

*编辑My_Appl ication_Folder \ config.php文件*

$config['base_url'] = '/#MY_DIRECTORY#'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

可能的解决方法2:

化妆的.htaccess

RewriteEngine on 
RewriteBase /#MY_DIRECTORY# 
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L] 

*编辑My_Application_Folder \ config.php文件*

$config['base_url'] = '/#MY_DIRECTORY#'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

注意:#MY_D IRECTORY#在活动服务器subdom目录(例如。 first.example.com) - 只是举例和处理在一个系统CI多个应用

不要忘了文件的规则htaccess的或输出自定义库

AddDefaultCharset UTF-8 

Header unset Pragma 
FileETag None 
Header unset ETag 

1年

设置
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"> 
Header set Cache-Control "public" 
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" 
Header unset Last-Modified 
</filesMatch> 

2小时

<filesMatch ".(html|htm|xml|txt|xsl)$"> 
Header set Cache-Control "max-age=7200, must-revalidate" 
</filesMatch> 

CACHED FOREVER/mod_rewrite的重命名每一个变化

<filesMatch ".(js|css)$"> 
Header set Cache-Control "public" 
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" 
Header unset Last-Modified 
</filesMatch>