How to redirect users to another page?

后端 未结 4 1029
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 23:17

I need to redirect users that visit a certain page without providing specific parameters in a query string. How to redirect users to another page the right way? So that the sear

相关标签:
4条回答
  • 2021-01-20 23:58
    <?php
        Header("HTTP/1.1 301 Moved Permanently"); 
        Header("Location: http://www.new-url.com");
        exit();
    ?> 
    

    The moved permanently is what helps with search engines.

    0 讨论(0)
  • 2021-01-20 23:59
    <?php
        Header("HTTP/1.1 302 Moved Temporarily"); 
        Header("Location: http://www.new-url.com");
        exit();
    ?> 
    
    0 讨论(0)
  • 2021-01-21 00:08

    <?php
    /* Redirect browser */
    header("Location: http://www.google.com");
     
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>

    Instead of http://www.google.com, you can write your own URL where you want to redirect your page.

    0 讨论(0)
  • 2021-01-21 00:14
    if($condition){
     header('Location: http://example.com');
     exit();
    }
    

    will do it. Don't forget the exit()!

    0 讨论(0)
提交回复
热议问题