I thought it should be a simple straight-forward matter but after struggling with it for too much time I’m gonna have to seek for help.
What I need is to redirect all requests for my web application that match the following pattern – “^(http://[^/]+/blogs/[^/.]+)/?$” to the path of “$1/Default.aspx“.
(Using English rather than Regex: http://myapp/blogs/randomdirthatdoesntexist -> http://myapp/blogs/randomdirthatdoesntexist/default.aspx)
The sub-directories in “blogs” do not physically exist, instead a 3rd party product deals with the requests to randomdir/Default.aspx”, but when you go to “randomdir/” you get 404 not found, which is what I’m trying to fix.
I tried to use global.asax and also HttpHandler, but I couldn’t get either of them to fire up on the requests to those 404 paths.
So, in short, what should I do to redirect paths of non-existing directories?
Thanks.
I accomplished something similar to this by setting the Error Page for 404s in IIS to a page you create. This page is able to access the page which is being requested, and perform some additional logic. So the 404 for randomdirthatdoesntexist/ still happens, but the 404 handler notices this and redirects to randomdirthatdoesntexist/default.aspx.
I dug out my old code and tweaked it a little to do what you need in an over-simplified fashion, but I don’t have IIS6 anywhere to test: