PHP header(Location: …): Force URL change in address bar

后端 未结 14 1565
失恋的感觉
失恋的感觉 2020-11-28 08:10

I\'m currently working on a mobile site with authentication using PHP sessions with a database. I have a login page with a form that goes to server_login.php

相关标签:
14条回答
  • 2020-11-28 08:26

    I had the same problem with posting a form. What I did was that turning off the data-ajax.

    0 讨论(0)
  • 2020-11-28 08:31

    why all of this location url?

    http://localhost:8080/meet2eat/index.php
    

    you can just use

    index.php
    

    if the php files are in the same folder and this is better because if you want to host the files or change the port you will have no problem reaching this URL.

    0 讨论(0)
  • 2020-11-28 08:32

    you may want to put a break; after your location:

    header("HTTP/1.1 301 Moved Permanently");
    header('Location:  '.  $YourArrayName["YourURL"]  );
    break;
    
    0 讨论(0)
  • 2020-11-28 08:32

    I got a solution for you, Why dont you rather use Explode if your url is something like

    Url-> website.com/test/blog.php

    $StringExplo=explode("/",$_SERVER['REQUEST_URI']);
    $HeadTo=$StringExplo[0]."/Index.php";
    Header("Location: ".$HeadTo);
    
    0 讨论(0)
  • 2020-11-28 08:35

    Do not use any white space. I had the same issue. Then I removed white space like:

    header("location:index.php"); or header('location:index.php');
    

    Then it worked.

    0 讨论(0)
  • 2020-11-28 08:35

    You are suppose to use it like header(Location:../index.php) if it in another folder

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