Ben
Ben

Reputation: 11

Get actual URL from address bar in Classic ASP on a 404 redirected page

I need to catch URLs that don't exist on my website and redirect them to relevant pages that do exist.

I have set up a custom 404 page on the web server and then in the 404 I look at the URL, decide where it should be going and then forward the page as follows:

Response.Status = "301 Moved Permanently"
Response.AddHeader("Location",thisPageString)

Where thisPageString is the new page URL.

However, when I access the page URL with...

Request.ServerVariables("PATH_INFO") 

...I get the current actual URL = "/404.asp"; when what I actually need is the original URL for the non-existent page shown in the address bar.

How do I access that?

Thanks.

Upvotes: 1

Views: 3975

Answers (1)

Yots
Yots

Reputation: 1685

You should get the info you are looking for from

request.servervariables("http_referer")

Update:

Try

request.servervariables("QUERY_STRING") 

you should get the info separated by ";"

Example: "404;http://unknown.asp"

Upvotes: 5

Related Questions