简体   繁体   中英

URL Rewriting not working with URL ending “.ad” or “.cd”

I'm having some difficulties with my custom URL-rewriting setup. I'm not using any 3rd party tool to manage this, just using the global.asax by looking at every request and processing it.

The way I am using it is like: www.mydomain.com/site/google.com

This page contains information about the site "google.com". I'm using the actual domain within the URL. This is all works fine.

I have simplified the code that I'm using just to show you an example of how it works:

Dim myContext As HttpContext = HttpContext.Current
Dim URL As String = myContext.Request.ServerVariables("URL")
If URL.ToLower.Contains("/site/") Then
    URL = URL.Trim("/")
    Dim strURL As String = URL.ToLower.Split("/")(1)
    Redirect301("/site.aspx?url=" & strURL)
    Exit Sub
End If

The issue I'm having is for certain domain extensions, the page will just load up custom 404 Not Found and I have no idea what the cause is.

Example of pages that don't load:

  • /site/google.ad
  • /site/google.cd

I'm guessing that the system thinks that .cd and .ad files are actual physical files and when it doesn't find them, it shows the custom 404 error. It doesn't actually looks like the request is getting through to the global.asax. When working in local environment, they actually load fine but only on the live server it has this issue and this is why it has been a nightmare trying to figure it out.

Another issue I found was loading the following URL:

  • /site/prn.com

This shows a 404 error again but this time not the custom one I created but the actual hard looking .net 404 error page. This also works fine in local environment.

There must be some IIS setting or code change I could do to try to get this resolved.

Thank you for your time :)

Aki

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM