0

I am using IIS and PHP. I have a custom 404 page which is a PHP script. On this page, I would like to display the original URL accessed. I am trying the following text plus server variable but it is just showing the site name and HTTP_REFERER is usually blank.

echo 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['HTTP_REFERER'];

What is the correct server variable(s) to use to get the raw URL in PHP/IIS.

This is the appropriate section in my web.config to call the custom 404 page:

<httpErrors>
  <remove statusCode="404" subStatusCode="-1" />
  <error statusCode="404" prefixLanguageFilePath="" path="/404.php" responseMode="Redirect" />
</httpErrors>
Rob Sedgwick
  • 4,342
  • 6
  • 50
  • 87

1 Answers1

3

Rather than use a redirect I do an ExecuteURL

<error statusCode="404" path="/404.php" responseMode="ExecuteURL" />

and for the variables to describe the page

echo 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
Rob Sedgwick
  • 4,342
  • 6
  • 50
  • 87