(Side note: I hate ASP. I love PHP. But sometimes mean people make me use ASP) ;o)
I needed to get the current page name and redirect to a different page if it was a certain name. (ie. 1.asp or 2.asp or… up to any two-digit + .asp)
First – to get the page name I used a script I found here:
Dim strURL, aryURL, pagename, objRegExp
strURL = Request.ServerVariables("SCRIPT_NAME")
aryURL = Split(strURL, "/", -1, 1)
pagename = aryURL(ubound(aryURL))
Then I check the page against a reg exp:
set objRegExp = new RegExp
objRegExp.Pattern = "^[0-9]{1,2}\.asp"
if objRegExp.Test(pagename) then
Response.Redirect("http://www.example.com/pageToRedirectTo.asp")
end if
(FYI – I'm trying to get a better grasp of regular expressions. I know they're useful, I just can't seem to wrap my head around them. We're still at the "it makes my eyes bleed" stage – which is also pretty much how I feel about ASP)