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?
try this <% If instr(Request.ServerVariables("SCRIPT_NAME"), "ProductDetails.asp")>0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "redirectURL" End If %>
Thank you for the reply ludwig. I did some reasearch with what you said and it seams if you use instr and > 0 it will scan for whatever you put inside instr and search for that string of text. If it's found, it's given a value of 1, so if it's 1 which is greater then 0, it will do the rewrite. Do I have that right? I'll spend some time playing around with your code... but I think it will do exactly what I want. Thanks again