cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IIS URL Rewrite Module Unresponsive

I have been adding and editing webserver rewrite rules in my asp.net web.config file. I was not getting the results I expected.  It was as if some of the rules were being ignored. According to the URL Rewrite Module Configuration Reference, certain parts of the URL string can be accessed using server variables. I assumed that every server variable would return what the documentation said, but this was not the case. The hard truth is that not every server variable returns what you would expect. Many of them do not return a value at all!.

 

I found this out by pasting the example code found in HttpRequest.ServerVariables Property in the code-behind of a test page on my web site, and ran it both locally and on the remote host to see what the page would render. From this I was able to learn what keys were most useful and whether their values differed between local and remote.  

 

These are the only server variables that were most useful to me, along with examples of the values they returned:

 

 LOCALREMOTE
{HTTPS}offoff
{HTTP_HOST}localhost:64085www.xyz.com
{URL}[url_parameter]xyz/[url_parameter]
{QUERY_STRING}x=5x=5
2 REPLIES 2
Employee
Employee

Re: IIS URL Rewrite Module Unresponsive

Hello @sheeand!

 

Thank you for posting! Which variables are not working? Can you provide some examples of what's not working? I'd also recommend reaching out to our support team on this.

 

Heather - GoDaddy | Community Moderator
24/7 support available at x.co/247support

Re: IIS URL Rewrite Module Unresponsive

Hi Heather - thanks for responding.  I've been able to do most of what I want to do (i.e., redirect root domain calls to www subdomain calls) with C# logic and redirects in my code-behind. All I have left is one rewrite rule in my web.config that is supposed to strip out any inadvertent addition of the host name that may appear in the url. For example, www.fixmyowntv.com/fixmyowntv/zoom will produce the same page as www.fixmyowntv.com/zoom, and I want to strip out the superfluous /fixmyowntv so that when the page renders, that path does not appear in the browser's url address field.

 

Here is the rewrite rule:

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Rewrite URL to omit fixmyowntv">
          <match url="(\/fixmyowntv)(.*)" ignoreCase="true" />
          <action type="Rewrite" url="{R:2}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

And, in full disclosure, this what's in my route.config:

            routes.MapRoute(
                name: "MVC - Article & Title",
                url: "{article}/{title}",
                defaults: new { controller = "Home", action = "Default", article = UrlParameter.Optional, title = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "MVC - Article",
                url: "{article}",
                defaults: new { controller = "Home", action = "Default", article = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "default",
                url: "",
                defaults: new { controller = "Home", action = "Default" }
            );

Any idea why the rewrite rule doesn't work remotely?