Knowledgebase
WordPress and IIS Rewrite Rules
Posted by Joe Rebis on 05 October 2012 01:02 PM

WordPress automatically creates a set of "Pretty URL" rewrite rules to the IIS web.config file when you even just visit the Permalinks area of WordPress (no save action is needed). In some configurations ( e.g. multiple WP installs in the same website) this could cause some problems and trigger the following error.

"Cannot add duplicate collection entry of type 'rule' with unique key attribute 'name' set to 'wordpress'"

To resolve or to future proof add the following line to the web.config file.

<remove name="wordpress" />

For example, like this:

<rewrite>
<rules>
<remove name="wordpress" />
<rule name="wordpress" patternSyntax="Wildcard">
<match url="/joe" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>

EPhost, Inc. customers can also enable common .HTACCESS rules (typcially on Apache) instead of (in addition to) the rules above. We have installed HeliconAPE in IIS which supports nearly all types of .HTACCESS configurations. You can create an .HTACCESS file by visiting the website settings page in the control panel and clicking on the .HTACCESS tab. The .HTACCESS rules will superceed the web.config rules. Please add the following text inside the .HTACCESS file (can be done by FTP too) which is located (typically) in the WWWROOT folder or the root of any WordPress application.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [NC,L]

NOTE: If you do use an .HTACCESS file you will still want to make the change above to "future proof" the installation. The web.config file is automatically generated by IIS, and WordPress will automatically create the WordPress rules above so it is useless to delete.

Thank you Paul Fox: http://foxsys.blogspot.com/2011/10/iis7-error-when-enabling-wordpress.html

(3 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Copyright © 2015 EPhost, Inc. All rights reserved.