首页 文章

Codeigniter中的.htaccess无法在远程服务器中运行

提问于
浏览
0

.htaccess文件在我的localhost中正常工作但是当我在远程服务器上上传时,重定向无法正常工作 .

当我与任何用户登录然后尝试从该站点注销然后它再次显示我已登录但它在我的本地Web服务器上正常工作

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

<Files "index.php">
AcceptPathInfo On
</Files>

这是我的退出控制器

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


 class logout extends CI_Controller { 

public function __construct()
{
     parent::__construct();
}

function index()
{
    $this->home_model->unsetsessions();
    redirect('', 'refresh');
}
}?>

1 回答

  • 0

    这个.htaccess在我的CI项目中运作良好:

    <IfModule mod_headers.c>
    
        # activate RewriteEngine
        RewriteEngine on
    
        # delete index.php from URL
        RewriteCond $1 !(index\.php|robots\.txt|humans\.txt|license\.txt|sitemap\.xml|assets)
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    
        # sitemap.xml to /sitemap
        RewriteRule ^sitemap\.xml$ index.php/sitemap [L]
    
        # no-www to www
        #change DOMNIO.COM
        RewriteCond %{HTTP_HOST} ^DOMNIO.COM$
        RewriteRule (.*) http://www.DOMNIO.COM/$1 [R=301,L]
    
    </IfModule>
    
    <IfModule !mod_rewrite.c>
    
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        ErrorDocument 404 /index.php
    </IfModule>
    

相关问题