How can I redirect another page in php?

This question already has an answer here:

  • How to make a redirect in PHP? 27 answers

  • This will work if you haven't written anything on the page yet:

    header( 'Location: http://www.yoursite.com/new_page.html' ) ;
    

    If you have, you'll have to use javascript for redirection:

    <script>window.location.href = "http://www.yoursite.com/new_page.html";</script>
    

    use this

    header( 'Location: http://www.yoursite.com/new_page.html' ) ;
    

    or

    header( 'Location: /somepage.php' ) ;
    

    for a local page.


    在页面上打印任何HTML之前,使用header函数来告知用户在其他位置发出的请求的位置,从而导致重定向到该页面。

    header('Location: login.php');
    
    链接地址: http://www.djcxy.com/p/34716.html

    上一篇: 点击提交后如何在html或php中打开链接?

    下一篇: 我如何重定向另一个页面在PHP?