0

我正在使用沉闷的重定向:

redirect('/home/login/');

当用户未登录时。但它不断将我重定向到

/index.php/home/login/

虽然我的 .htaccess 中有这个:

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

1 回答 1

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_Application_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_DIRECTORY# 位于实时服务器子域目录(例如 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>
于 2013-03-01T06:57:34.357 回答