I've been struggling with trying to apply a rewrite rule to my site, running IIS7 on Windows Server 2008, hosting an ASP site running in "Classic" Managed Pipeline Mode(Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4223). Hopefully
my full explanation of the issue makes sense.
In my dev environment, our "main" web site is nested a few folders deep under the Sites folder on IIS Manager, as we have several other sites and services elsewhere. That site has a web.config, and there are no other web.config files in any of the directories
above it in the folder hierarchy. When that main site is deployed to test/production web servers, it is the only site deployed to IIS on those boxes, and is the only site under "Default Web Site" in the Sites directory in IIS Manager. The web.config file in
the root directory for that site is the only web.config that exists on these boxes.
In my dev environment, if I create a URL rewrite rule using the GUI and apply it at any directory level higher than my main web site, it will create a web.config in the given directory that has only a system.webServer section with the rewrite rule I just
created. This rewrite rule works for the main site that is in a subdirectory from where this newly created web.config exists. However, if I create a rewrite rule at the root directory level for my main site, it adds the rewrite rule to the site's web.config
(as expected), but the rewrite rules do not take effect. Similarly, if I add them on my test/prod servers at the site level so that they are added to the site's web.config, the rewrite rules also are not applied.
In test/prod I need to have the rewrite rules applied at the location of my main site's web.config, as it's the only location where I can place a web.config file.
Has anybody else encountered an issue like this? Any suggestions? Thanks.
Sorry for disabling to grasp your question exatctly.
It's seems a configuration hierarchy issue.
A configuration hierarchy is defined and calculated for the configuration settings of the system. The hierarchy starts at machine.config, then progresses to the root web.config file, followed by applicationHost.config. From then on, any optional web.config
file that is located at the site, application or virtual directory level is added and applied to the hierarchy. At the end, the properties inherit from parent to child file from machine.config down to the last web.config file (if any) and the effective configuration
is calculated for a given path.
The inheritance behavior is done by default. Any setting at a lower level in the hierarchy overrides a parent setting defined in a file above the current level. However, going further down the hierarchy, the scope of configuration is more limited. Where
as the machine.config, root web.config and applicationHost.config files' settings apply to everything in the system, optional web.config files' settings only apply to the current location and below (whether it is a site, application or virtual directory).
For more inforamtion about Configuration Hierarchy please refer to this:
Thanks for the reply. I've set the rewrite rule in applicationHost.config on my test environment server, and the rewrite rule is still not being applied. I will investigate further up/down the hierarchy to see if I can find the sweet spot.
jbrandhorst
2 Posts
Rewrite rule not being applied when in "main" web.config
Mar 29, 2012 01:28 PM|LINK
Hi all,
I've been struggling with trying to apply a rewrite rule to my site, running IIS7 on Windows Server 2008, hosting an ASP site running in "Classic" Managed Pipeline Mode(Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4223). Hopefully my full explanation of the issue makes sense.
In my dev environment, our "main" web site is nested a few folders deep under the Sites folder on IIS Manager, as we have several other sites and services elsewhere. That site has a web.config, and there are no other web.config files in any of the directories above it in the folder hierarchy. When that main site is deployed to test/production web servers, it is the only site deployed to IIS on those boxes, and is the only site under "Default Web Site" in the Sites directory in IIS Manager. The web.config file in the root directory for that site is the only web.config that exists on these boxes.
In my dev environment, if I create a URL rewrite rule using the GUI and apply it at any directory level higher than my main web site, it will create a web.config in the given directory that has only a system.webServer section with the rewrite rule I just created. This rewrite rule works for the main site that is in a subdirectory from where this newly created web.config exists. However, if I create a rewrite rule at the root directory level for my main site, it adds the rewrite rule to the site's web.config (as expected), but the rewrite rules do not take effect. Similarly, if I add them on my test/prod servers at the site level so that they are added to the site's web.config, the rewrite rules also are not applied.
In test/prod I need to have the rewrite rules applied at the location of my main site's web.config, as it's the only location where I can place a web.config file.
Has anybody else encountered an issue like this? Any suggestions? Thanks.
IIS7 web.config url rewrite 2.0
Mamba Dai - ...
651 Posts
Microsoft
Re: Rewrite rule not being applied when in "main" web.config
Apr 02, 2012 06:02 AM|LINK
Hi,
Sorry for disabling to grasp your question exatctly.
It's seems a configuration hierarchy issue.
A configuration hierarchy is defined and calculated for the configuration settings of the system. The hierarchy starts at machine.config, then progresses to the root web.config file, followed by applicationHost.config. From then on, any optional web.config file that is located at the site, application or virtual directory level is added and applied to the hierarchy. At the end, the properties inherit from parent to child file from machine.config down to the last web.config file (if any) and the effective configuration is calculated for a given path.
The inheritance behavior is done by default. Any setting at a lower level in the hierarchy overrides a parent setting defined in a file above the current level. However, going further down the hierarchy, the scope of configuration is more limited. Where as the machine.config, root web.config and applicationHost.config files' settings apply to everything in the system, optional web.config files' settings only apply to the current location and below (whether it is a site, application or virtual directory).
For more inforamtion about Configuration Hierarchy please refer to this:
http://learn.iis.net/page.aspx/122/getting-started-with-configuration-in-iis-7-and-above/
BTW, if this still doesn't work for your problem, please clarify your question
Feedback to us
Develop and promote your apps in Windows Store
jbrandhorst
2 Posts
Re: Rewrite rule not being applied when in "main" web.config
Apr 03, 2012 04:24 PM|LINK