krishna
krishna

Reputation: 1199

URL redirecting in classic asp

My application url is like this.

http://somename/webname/default.asp

It also contains some other default.asp like http://somename/webname/booking/default.asp and some others too. Even if user tries to access other default.asp, I want them to redirect to

http://somename/webname/default.asp.

Update: I have been checking like this in global.asa.

Application("txtPathInfo") = Request.ServerVariables("PATH_INFO")
if (Application("txtPathInfo") <> "/webname/default.asp")   then
Response.Redirect("/webname/default.asp")
end if

But the problem is, first time it is working fine,redirecting to desired page. Next attempt it allows, may be the global.asa is not called while trying to access in same session. Please anyone provide some feasible solution on this. Thanks :)

Upvotes: 0

Views: 585

Answers (1)

Andy Davies
Andy Davies

Reputation: 1446

One quick way is to put this code in a default.asp page in each possible folder.

<%
Response.Redirect "http://somername/default.asp"
%>

If there are too many folders or some of those folders don't physically exist you'll need to use a url rewrite rule or code within a custom 404 error page.

For rewrite rules this will depend on which version of IIS you are running. If IIS6 then I'd recommend IIRF but if you're running IIS7 or IIS8 then use the built in url rewrite module (installed via Web Platform Installer).

Upvotes: 2

Related Questions