开发者

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

开发者 https://www.devze.com 2023-03-26 21:17 出处:网络
I need to catch URLs that don\'t exist on my website and redirect them to relevant pages that do exist.

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("PAT开发者_运维知识库H_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.


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"

0

精彩评论

暂无评论...
验证码 换一张
取 消