Get original url for 404 page

后端 未结 2 1334
终归单人心
终归单人心 2021-01-13 14:54

So I have found these two questions:

Accessing original URL in IIS7 404 redirect page Get URL of page requested that caused a 404

but they are both in diffe

相关标签:
2条回答
  • 2021-01-13 15:30

    Can't it be in $_SERVER['HTTP_REFERER'] variable?

    See http://php.net/manual/en/reserved.variables.server.php

    0 讨论(0)
  • 2021-01-13 15:34

    Since you are using PHP, you would be having access to the various PHP superglobals. $_SERVER['SCRIPT_NAME'], $_SERVER['REQUEST_URI'] etc can be used for the purpose. Something like this in the error page should do:

    <?php
        printf("The page %s was not found.", $_SERVER['REQUEST_URI']);
    ?>
    

    For more, do have a look at the $_SERVER superglobal documentation.

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