[wp-trac] [WordPress Trac] #23748: Suggest rewrite rules on IIS Network (Multisite)

WordPress Trac noreply at wordpress.org
Tue Mar 12 18:23:35 UTC 2013


#23748: Suggest rewrite rules on IIS Network (Multisite)
-----------------------------+--------------------------
 Reporter:  guy_fr           |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Multisite
  Version:  3.5.1            |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 Server: Microsoft IIS - 8
 Wordpress: 3.5.1 (multisite)

 On subfolder install, suggest for web.config is:
 {{{
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <system.webServer>
         <rewrite>
             <rules>
                 <rule name="WordPress Rule 1" stopProcessing="true">
                     <match url="^index\.php$" ignoreCase="false" />
                     <action type="None" />
                 </rule>
                 <rule name="WordPress Rule for Files"
 stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?files/(.+)"
 ignoreCase="false" />
                     <action type="Rewrite" url="wp-includes/ms-
 files.php?file={R:1}" appendQueryString="false" />
                 </rule>
                 <rule name="WordPress Rule 2" stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?wp-admin$"
 ignoreCase="false" />
                     <action type="Redirect" url="{R:1}wp-admin/"
 redirectType="Permanent" />
                 </rule>
                 <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="^" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile"
 ignoreCase="false" />
                         <add input="{REQUEST_FILENAME}"
 matchType="IsDirectory" ignoreCase="false" />
                     </conditions>
                     <action type="None" />
                 </rule>
                 <rule name="WordPress Rule 4" stopProcessing="true">
                     <match url="^([_0-9a-
 zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                     <action type="Rewrite" url="{R:1}" />
                 </rule>
                 <rule name="WordPress Rule 5" stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?([_0-9a-
 zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                     <action type="Rewrite" url="{R:2}" />
                 </rule>
                 <rule name="WordPress Rule 6" stopProcessing="true">
                     <match url="." ignoreCase="false" />
                     <action type="Rewrite" url="index.php" />
                 </rule>
             </rules>
         </rewrite>
     </system.webServer>
 </configuration>
 }}}

 On sudomain install, it is:
 {{{
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <system.webServer>
         <rewrite>
             <rules>
                 <rule name="WordPress Rule 1" stopProcessing="true">
                     <match url="^index\.php$" ignoreCase="false" />
                     <action type="None" />
                 </rule>
                 <rule name="WordPress Rule for Files"
 stopProcessing="true">
                     <match url="^files/(.+)" ignoreCase="false" />
                     <action type="Rewrite" url="wp-includes/ms-
 files.php?file={R:1}" appendQueryString="false" />
                 </rule>
                 <rule name="WordPress Rule 2" stopProcessing="true">
                     <match url="^wp-admin$" ignoreCase="false" />
                     <action type="Redirect" url="wp-admin/"
 redirectType="Permanent" />
                 </rule>
                 <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="^" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile"
 ignoreCase="false" />
                         <add input="{REQUEST_FILENAME}"
 matchType="IsDirectory" ignoreCase="false" />
                     </conditions>
                     <action type="None" />
                 </rule>
                 <rule name="WordPress Rule 4" stopProcessing="true">
                     <match url="^(wp-(content|admin|includes).*)"
 ignoreCase="false" />
                     <action type="Rewrite" url="{R:1}" />
                 </rule>
                 <rule name="WordPress Rule 5" stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$"
 ignoreCase="false" />
                     <action type="Rewrite" url="{R:2}" />
                 </rule>
                 <rule name="WordPress Rule 6" stopProcessing="true">
                     <match url="." ignoreCase="false" />
                     <action type="Rewrite" url="index.php" />
                 </rule>
             </rules>
         </rewrite>
     </system.webServer>
 </configuration>
 }}}

 I think that Wordpress Rules for files and Wordpress Rule 4 and 5 should
 follow same rules than htaccess suggest.
 When following actual suggest in a subfolder installation, I get an HTPP
 Error in call to sub site, error is always reproductible for me - can you
 confirm.

 A fix could be to add a subdir replacement rule {R:1} for subdomain
 install and {R:2} for subfolder.

 Implementation in the network.php file (adding
 $iis_subdir_replacement_12):
 {{{
 $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
 $iis_subdir_replacement_12 = $subdomain_install ? '{R:1}' : '{R:2}';

 $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <system.webServer>
         <rewrite>
             <rules>
                 <rule name="WordPress Rule 1" stopProcessing="true">
                     <match url="^index\.php$" ignoreCase="false" />
                     <action type="None" />
                 </rule>';
                                 if ( is_multisite() && get_site_option(
 'ms_files_rewriting' ) ) {
                                         $web_config_file .= '
                 <rule name="WordPress Rule for Files"
 stopProcessing="true">
                     <match url="^' . $iis_subdir_match . 'files/(.+)"
 ignoreCase="false" />
                     <action type="Rewrite" url="' . $iis_rewrite_base .
 'wp-includes/ms-files.php?file='.$iis_subdir_replacement_12.'"
 appendQueryString="false" />
                 </rule>';
                 }
                 $web_config_file .= '
                 <rule name="WordPress Rule 2" stopProcessing="true">
                     <match url="^' . $iis_subdir_match . 'wp-admin$"
 ignoreCase="false" />
                     <action type="Redirect" url="' .
 $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
                 </rule>
                 <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="^" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile"
 ignoreCase="false" />
                         <add input="{REQUEST_FILENAME}"
 matchType="IsDirectory" ignoreCase="false" />
                     </conditions>
                     <action type="None" />
                 </rule>
                 <rule name="WordPress Rule 4" stopProcessing="true">
                     <match url="^' . $iis_subdir_match .
 '(wp-(content|admin|includes).*)" ignoreCase="false" />
                     <action type="Rewrite" url="' . $iis_rewrite_base .
 $iis_subdir_replacement_12 . '" />
                 </rule>
                 <rule name="WordPress Rule 5" stopProcessing="true">
                     <match url="^' . $iis_subdir_match . '([_0-9a-
 zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                     <action type="Rewrite" url="' . $iis_rewrite_base .
 $iis_subdir_replacement_12 . '" />
                 </rule>
                 <rule name="WordPress Rule 6" stopProcessing="true">
                     <match url="." ignoreCase="false" />
                     <action type="Rewrite" url="index.php" />
                 </rule>
             </rules>
         </rewrite>
     </system.webServer>
 </configuration>';
 }}}

 Sorry for my english :)

 regards

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23748>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list