Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
969 views
in Technique[技术] by (71.8m points)

codeigniter - Redirecting function not redirecting

I try to redirect to a specific function in the same controller, but it doesn't redirect and only shows a white page (blank).

Trying to redirect to some specific url, it's still not moving to the url.

signin controller:

public function index() 
    {
    
        $this->generateToken();

        $data = array(
            'title' => 'MASUK',
            'breadcrumb' => 'MASUK',
            'menu' => 'MASUK',
            'login' => 'active',
            'captcha' => $this->refresh_captcha(),
            'msg' => '',
            'infoMSG' => ''
        );
    
        if (isset($this->session->userdata['logged_in']['usr_email']) == "") {

            $this->template->load('template', 'signin', $data);
        } else {
         //var_dump(base_url());  // show the base url 
         //redirect('https://www.facebook.com');  // not direct to specific url too
         redirect('Signin/logout');
        }
        // else {
        // redirect('landing');
        // }
    }


 public function logout()
    {
    print_r("mask");  //not print anything 
            $this->load->library('session');
    
        $this->session->unset_userdata('permission');
        $this->session->unset_userdata('logged_in');
        $this->session->unset_userdata('session');
        $this->session->unset_userdata('userinfo');
        $this->session->unset_userdata('api_loc');
        $this->session->sess_destroy();
    
        redirect('signin');
    }

.htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
question from:https://stackoverflow.com/questions/65859055/redirecting-function-not-redirecting

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding a ? at the end of index.php in your last rewrite rule.

RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

If that doesn't work, try changing your config.php 'uri_protocol' if it's set to AUTO.

$config['uri_protocol'] = 'REQUEST_URI';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...