Redirect with CodeIgniter

后端 未结 5 1197
天命终不由人
天命终不由人 2020-11-27 03:52

Can anyone tell me why my redirect helper does not work the way I\'d expect it to? I\'m trying to redirect to the index method of my main controller, but it takes me w

5条回答
  •  没有蜡笔的小新
    2020-11-27 04:08

    redirect()

    URL Helper


    The redirect statement in code igniter sends the user to the specified web page using a redirect header statement.

    This statement resides in the URL helper which is loaded in the following way:

    $this->load->helper('url');
    

    The redirect function loads a local URI specified in the first parameter of the function call and built using the options specified in your config file.

    The second parameter allows the developer to use different HTTP commands to perform the redirect "location" or "refresh".

    According to the Code Igniter documentation: "Location is faster, but on Windows servers it can sometimes be a problem."

    Example:

    if ($user_logged_in === FALSE)
    {
         redirect('/account/login', 'refresh');
    }
    

提交回复
热议问题