Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4032350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:42:38+00:00 2026-05-20T11:42:38+00:00

I thought it should be a simple straight-forward matter but after struggling with it

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:42:38+00:00Added an answer on May 20, 2026 at 11:42 am

    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:

    protected void Page_Load(object sender, EventArgs e)
    {
        String sQueryString = Request.RawUrl.Substring(Request.FilePath.Length);
        Regex rx = new Regex(@"^\?(?<errorcode>\d+);(?<args>.*)$", RegexOptions.ExplicitCapture | RegexOptions.Compiled);
        Match m = rx.Match(sQueryString);
    
    
        if (m.Success)
        {
            if (m.Groups["errorcode"].Value == "404")
            {
                String sArgs = m.Groups["args"].Value;
                Uri requestedUri = new Uri(sArgs);
    
                // You can now check the value of uri and perform redirection...
                if (requestedUri.ToString().EndsWith("/"))
                {
                    Response.Redirect(requestedUri + "Default.aspx")
                }
            }
        }
        Response.StatusCode = 404;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this should not be hard but I'm struggling with it so I thought I'd
This should be relatively easy to do, but after several hours straight programming my
I thought it should be a config file, but cannot find it. thanks
Okay so I'm kind of new with OpenGL, but I thought I should learn
I thought the following line of code should work fine: $(.1).attr('href', '#Home'); Right? But
I have always thought that the .equals() method in java should be overridden to
Source RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely
I'm having trouble with what I thought should be a pretty simple problem. I
The question should be simple, but i'm thinking what the best way to do
I thought that this would be simple enough, but I just can't get my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.