Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#36544 closed defect (bug) (duplicate)

Check for existing rewrite rule fails on IIS

Reported by: jbiddle86's profile jbiddle86 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5
Component: Rewrite Rules Keywords:
Focuses: Cc:


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="*" />
				<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
				<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
		<action type="Rewrite" url="index.php" />

Change History (1)

#1 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @jbiddle86, welcome to Trac!

Thanks for the report, we're already tracking this issue in #36506.

Note: See TracTickets for help on using tickets.