0


Is there any way in ASP Classic to catch HTTP request before it comes to that page? Like in ASP.Net we can catch request at Application_BeginRequest.

Actually what I'm trying to do is to redirect requests to some other pages if asking files from a certain directory. My application is hosted on IIS6. And I suppose IIS6 by default doesn't support for url rewrite. Directory browsing is already disabled.

It would be nice if it could be done just putting a web.config in that certain directory to redirect to other pages.

e.g.

Original Requests: 
Https://stackoverflow.com/NoReadWriteFolder/file1.asp
Https://stackoverflow.com/NoReadWriteFolder/file2.html etc

and I'd like to redirect to 
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile1.asp
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile2.html

I googled but so far no luck, any clue would highly be appreciated.

c-sharp
  • 573
  • 1
  • 9
  • 25

2 Answers2

0

background: My application runs for different companies (countries in actual fact) that use the same application.

I use include file called default.asp that runs as standard include for all the scripts I serve. I catch domain requests in URL, detect which company this and then redirect to a URL that I build that includes company code and a "URL prefix" which is added to the URL throughout the session.

To do this, I read URL using request.servervariables, set Session variables, work out my URL prefix and based on this, create revised URL which I then response.redirect.

I hope this may give you an idea for your situation.

allski
  • 96
  • 7
0

For IIS6 I have used Ionic's Isapi Rewrite Filter

https://iirf.codeplex.com/

It supports URL re-writes and re-direction and should do exactly what you need.

On the examples and help pages there are examples for you to re-direct.

silver
  • 650
  • 4
  • 15
  • :Thank you for the rewrite library link. Yeah this is the only solution so far I got. Actually I was trying to find a way in which we don't have to install something on server. – c-sharp Jun 03 '14 at 13:20
  • For II6 there are no native options for URL re-writes, I recommend this app, I have used it for years without problems. – silver Jun 05 '14 at 07:11