Error: Rewrite/globalRules cannot be read

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.

IIS stores majority of its configuration in the applicationHost.config file. If there are syntax errors or missing entries in this file, one or more IIS features may not work. In this case, IIS may display an error in this case. In my case, IIS showed the error message below once we tried to open URL Rewrite module in IIS Manager:
 
There was an error while performing this operation.
Filename:
\\?\C:\Windows\system32\inetsrv\config\applicationHost.config
Error: The configuration section ‘system.webServer/rewrite/globalRules’ cannot be read because it is missing a section declaration
 
URL-rewrite-error.jpg


Solution

 
Follow steps below for solution. Please back up your applicationHost.config file first.
 
  • In IIS server, check if this file exists: %SystemRoot%\system32\inetsrv\rewrite.dll. If the file exists, continue the steps below. If it doesn’t, search for the file in server. If it doesn’t exist, it means URL Rewrite is not installed. It should be installed first
  • Open applicationHost.config file
  • Add the following line into the <globalModules> section

 

<add name="RewriteModule" image="%SystemRoot%\system32\inetsrv\rewrite.dll" />

 

  • Add the lines below in the <configSections> section:

 

<sectionGroup name="rewrite"> <section name="globalRules" overrideModeDefault="Deny" allowDefinition="AppHostOnly" /> <section name="rules" overrideModeDefault="Allow" /> <section name="outboundRules" overrideModeDefault="Allow" /> <section name="providers" overrideModeDefault="Allow" /> <section name="rewriteMaps" overrideModeDefault="Allow" /> <section name="allowedServerVariables" overrideModeDefault="Deny" /> </sectionGroup>

 

  • Add your URL Rewrite rule in the <system.webServer> section. Example:

 

<rewrite> <globalRules> <rule name="Remove authToken parameter from Query String" enabled="true" stopProcessing="true"> … </rule> </globalRules> </rewrite>

 

  • Save the file
  • Reset IIS

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.