[wp-trac] [WordPress Trac] #36544: Check for existing rewrite rule fails on IIS

WordPress Trac noreply at wordpress.org
Fri Apr 15 20:51:45 UTC 2016


#36544: Check for existing rewrite rule fails on IIS
---------------------------+-----------------------------
 Reporter:  jbiddle86      |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Rewrite Rules  |    Version:  4.5
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 We're having an issue with duplicate rules being written to the web.config
 when the permalinks are saved.

 When the permalinks are saved, the function iis7_add_rewrite_rule() does a
 check for an existing wordpress rule by looking for the string 'wordpress'
 in the name attribute.  Wordpress 4.5 updated the rewrite rule generation
 to support multiple installs in one hosting account, when this was done
 the start of the name attribute was changed to "Wordpress".  XPath appears
 to be case sensitive so the new name is failing the old check and rule is
 being written to the config file multiple times and causing IIS to throw a
 500 error.

 When we manually change the name attribute to start with 'wordpress' in
 all lower case the duplicate.

 Starts at line 565 in wp-admin/includes/misc.php:
 {{{
 $wordpress_rules =
 $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-
 with(@name,\'wordpress\')]');
         if ( $wordpress_rules->length > 0 )
                 return true;
 }}}

 Starts at line 1596 in wp-includes/class-wp-rewrite.php
 {{{
 $rules .= '
         <rule name="WordPress: ' . esc_attr( home_url() ) . '"
 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>';
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36544>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list