Forum Moderators: open

Message Too Old, No Replies

Checking the URL using ASP (not using Request.ServerVariabls)

         

midoriweb

8:51 am on Feb 16, 2007 (gmt 0)

10+ Year Member



I want to do something like

If URL Contains /ProductDetails.asp
Then
Redirect
End If

I used the code below but it doesn't work perfectly:

<%
If Request.ServerVariables("url") = "/ProductDetails.asp" Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "redirectURL"
End If
%>

The above code seems to check with the server what URL is being called. However, I'm rewriting URLs to make them SEO friendly and the code above won't let me redirect correctly.

So... my question is... is there a way using ASP that I can check the URL for a string not using the ServerVariables command?

skeletor

2:30 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



There are server variables other than URL that will give you the name of the page, such as PATH_INFO and SCRIPT_NAME. You can also use PATH_TRANSLATED to get the full path of the asp page on the server.

Other than that, the only way I can think of would be to append "?url="(insert the entire url)"" to the end of the url and then use Request.QueryString("url") to grab it.