[wp-trac] [WordPress Trac] #36506: Duplicate directives in web.config after WordPress 4.5 installation on Windows

WordPress Trac noreply at wordpress.org
Thu Apr 21 07:20:49 UTC 2016


#36506: Duplicate directives in web.config after WordPress 4.5 installation on
Windows
------------------------------+-------------------------
 Reporter:  oneumyvakin       |       Owner:  swissspidy
     Type:  defect (bug)      |      Status:  assigned
 Priority:  normal            |   Milestone:  4.5.1
Component:  Rewrite Rules     |     Version:  4.5
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+-------------------------

Comment (by JanR):

 Replying to [comment:13 swissspidy]:
 > @webshaun Are you able to test the latest patch on your install? That
 would be great!

 I can confirm the issue, WordPress 4.5 on IIS 8.5 breaks upon saving
 permalinks. On my vanilla WP test environment, I have one rewrite rule to
 rewrite non-www to www:

 {{{#!xml
 <rewrite>
   <rules>
     <rule name="non-www to www" stopProcessing="true">
       <match url="(.*)" ignoreCase="false"/>
       <conditions logicalGrouping="MatchAll">
         <add input="{HTTP_HOST}" pattern="^example\.com$"/>
         <add input="{URL}" pattern="(.+)" ignoreCase="false"/>
       </conditions>
       <action type="Redirect" url="http://www.example.com/{R:1}"
 redirectType="Permanent"/>
     </rule>
   </rules>
 </rewrite>
 }}}

 When I save my Permalinks, for example to /%postname%/, the rewrite rule
 is saved ''twice''. Resulting in a broken site and IIS HTTP Error 500.52 -
 URL Rewrite Module Error:

 > Cannot add duplicate collection entry of type 'rule' with unique key
 attribute 'name' set to 'WordPress: http://www.example.com'

 Furthermore, the existing rewrite plus the first WordPress rewrite rule
 are placed on one line, making it hardly readable:

 {{{#!xml
 <rewrite>
   <rules><rule name="non-www to www" stopProcessing="true"><match
 url="(.*)" ignoreCase="false"/><conditions logicalGrouping="MatchAll"><add
 input="{HTTP_HOST}" pattern="^example\.com$"/><add input="{URL}"
 pattern="(.+)" ignoreCase="false"/></conditions><action type="Redirect"
 url="http://www.example.com/{R:1}" redirectType="Permanent"/></rule><rule
 name="WordPress: http://www.example.com" patternSyntax="Wildcard"><match
 url="*"/><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>
   <rule name="WordPress: http://www.example.com" patternSyntax="Wildcard">
     <match url="*"/>
       <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>

 }}}

 Now, when I apply the patch `misc.php.3` @WiZZarD_ created manually and
 remove my web.config rewrites, the result is:

 * existing rewrite rule(s) still placed on one long line
 * a '''working WordPress website'''

 Web.config rewrite end result:

 {{{#!xml
 <rewrite>
   <rules><rule name="non-www to www" stopProcessing="true"><match
 url="(.*)" ignoreCase="false"/><conditions logicalGrouping="MatchAll"><add
 input="{HTTP_HOST}" pattern="^example\.com$"/><add input="{URL}"
 pattern="(.+)" ignoreCase="false"/></conditions><action type="Redirect"
 url="http://www.example.com/{R:1}" redirectType="Permanent"/></rule>
   <rule name="WordPress: http://www.example.com" patternSyntax="Wildcard">
     <match url="*"/>
       <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>
 }}}

 Now someone to fix `function saveDomDocument()` on line 626, but that's a
 different issue. This Permalink issue seems resolved with @WiZZarD_'s
 patch.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36506#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list