What is redirect used for?

Closed due to the fact that the essence of the question is not clear to the participants of Denis , Alex , Kromster , user194374, pavel 18 Dec '16 at 13:08 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    It would seem, what have MySQL and PHP ... ... - Akina

2 answers 2

$remember = (bool) $this->input->post('remember'); if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { redirect('admin', 'refresh'); } else { $this->session->set_flashdata('message',$this->ion_auth->errors()); redirect('admin/user/login', 'refresh'); } 

See an example. If authorization has passed, we redirect the user to the admin page. If not, then redirect to admin / user / login. In other words, redirect is a redirect.

    There are many reasons for using a redirect: for example, a redirect from one site to another or from one page to another. For example, your site has changed the domain old.domain.com and you would like people to access it on new.domain.com. These redirects are the most common and have the code 301

    Another type of popular 404 redirect is when a user tries to reach a non-existent address on your site, in which case all users will be directed to the page "Sorry, but this page does not exist"

    Not less common redirect 403 - this code means that the user does not have access rights to this page.

    Another example: the user must be sent to a specific page of the site after certain actions. For example, the user paid for the order and we redirect to the page "Thank you for your purchase"

    And such Vavriantov can be mass.

    You can read more here.

    The important point is that if we redirect to php, then no data should be sent to the user for output, even a blank line, otherwise the redirect will not occur. You can read here