Pick the string of a non-existent request

Asked

Viewed 108 times

0

How to pick the string of a non-existent request?

I am using . htaccess to redirect missing url requests (error 404).

But I would like when the 404.php page was displayed, I would like to pick up the missing url that the client typed. That is, the missing url!

Has as?

$_SERVER["HTTP_REFERER"] did not work! Returned empty value!

php page

  <h1>Oh não! 404 Página Não Encontrada!</h1>
  <p>
    O que você tentou encontrar não está aqui.
  </p>

  <br /> <br />

  <h2>Detalhes:</h2>

  <ul>
    <li>URI que você tentou: <?php echo $_SERVER["HTTP_REFERER"]; ?></li>
    <li>Data atual: <?php echo date("d/m/Y"); ?></li>
  </ul>

  <br /><br /><br />

.htaccess

<IfModule mod_rewrite.c>

    RewriteEngine On

    ErrorDocument 400 http://localhost/php/andre/provedor/index.php
    ErrorDocument 401 http://localhost/php/andre/provedor/401.php
    ErrorDocument 403 http://localhost/php/andre/provedor403.php
    ErrorDocument 404 http://localhost/php/andre/provedor/404.php
    ErrorDocument 500 http://localhost/php/andre/provedor/500.php
</IfModule>
  • Try $url = 'http://'. $_SERVER["SERVER_NAME"]. $_SERVER["REQUEST_URI"];

  • Gave the error page itself! What I wanted the non-existent page that the client tried to access!

  • You may have to deal with some PHP file, because I think . htaccess will redirect whenever you find the error. Use an index.php and handle page navigations

  • yes. But imagine the customer tries site/pageInextant.php I wanted the 404.php page to get this url. If the url was existing and 404.php received this redirect, the reuquest_uri took the value of the url

  • is.. but I think in practice it doesn’t work, because who is treating this is the . htaccess, and I don’t think it has the function to record this page that the client tried for it.

  • This won’t be easy as you won’t get to access any page!

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.