Ticket #12758: new_iis_rewrite_rules.diff
File new_iis_rewrite_rules.diff, 17.1 KB (added by , 15 years ago) |
---|
-
wp-admin/network.php
324 324 ?> 325 325 </li> 326 326 <?php 327 // Construct an htaccess file. 328 $htaccess_file = 'RewriteEngine On 329 RewriteBase ' . $base . ' 330 RewriteRule ^index\.php$ - [L] 331 332 # uploaded files 333 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; 334 335 if ( ! $subdomain_install ) 336 $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n"; 337 338 $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR] 339 RewriteCond %{REQUEST_FILENAME} -d 340 RewriteRule ^ - [L]'; 341 342 // @todo custom content dir. 343 if ( ! $subdomain_install ) 344 $htaccess_file .= "\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] 345 RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]'; 346 347 $htaccess_file .= "\nRewriteRule . index.php [L]"; 348 349 ?> 350 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 351 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>"> 352 <?php echo wp_htmledit_pre( $htaccess_file ); ?> 353 </textarea></li> 327 if (iis7_supports_permalinks()) { 328 if (is_subdomain_install()) { 329 $web_config_file = 330 '<?xml version="1.0" encoding="UTF-8"?> 331 <configuration> 332 <system.webServer> 333 <rewrite> 334 <rules> 335 <rule name="WordPress Rule 1" stopProcessing="true"> 336 <match url="^index\.php$" ignoreCase="false" /> 337 <action type="None" /> 338 </rule> 339 <rule name="WordPress Rule 2" stopProcessing="true"> 340 <match url="^files/(.+)" ignoreCase="false" /> 341 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> 342 </rule> 343 <rule name="WordPress Rule 3" stopProcessing="true"> 344 <match url="^" ignoreCase="false" /> 345 <conditions logicalGrouping="MatchAny"> 346 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> 347 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> 348 </conditions> 349 <action type="None" /> 350 </rule> 351 <rule name="WordPress Rule 4" stopProcessing="true"> 352 <match url="." ignoreCase="false" /> 353 <action type="Rewrite" url="index.php" /> 354 </rule> 355 </rules> 356 </rewrite> 357 </system.webServer> 358 </configuration>'; 359 } else { 360 $web_config_file = 361 '<?xml version="1.0" encoding="UTF-8"?> 362 <configuration> 363 <system.webServer> 364 <rewrite> 365 <rules> 366 <rule name="WordPress Rule 1" stopProcessing="true"> 367 <match url="^index\.php$" ignoreCase="false" /> 368 <action type="None" /> 369 </rule> 370 <rule name="WordPress Rule 2" stopProcessing="true"> 371 <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> 372 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> 373 </rule> 374 <rule name="WordPress Rule 3" stopProcessing="true"> 375 <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> 376 <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> 377 </rule> 378 <rule name="WordPress Rule 4" stopProcessing="true"> 379 <match url="^" ignoreCase="false" /> 380 <conditions logicalGrouping="MatchAny"> 381 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> 382 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> 383 </conditions> 384 <action type="None" /> 385 </rule> 386 <rule name="WordPress Rule 5" stopProcessing="true"> 387 <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" /> 388 <action type="Rewrite" url="{R:2}" /> 389 </rule> 390 <rule name="WordPress Rule 6" stopProcessing="true"> 391 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> 392 <action type="Rewrite" url="{R:2}" /> 393 </rule> 394 <rule name="WordPress Rule 7" stopProcessing="true"> 395 <match url="." ignoreCase="false" /> 396 <action type="Rewrite" url="index.php" /> 397 </rule> 398 </rules> 399 </rewrite> 400 </system.webServer> 401 </configuration>'; 402 } 403 ?> 404 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 405 <textarea class="code" readonly="readonly" cols="100" rows="20"> 406 <?php echo wp_htmledit_pre( $web_config_file ); ?> 407 </textarea></li> 354 408 </ol> 355 <?php if ( !is_multisite() ) { ?> 409 <?php } else { 410 // Construct an htaccess file. 411 $htaccess_file = 'RewriteEngine On 412 RewriteBase ' . $base . ' 413 RewriteRule ^index\.php$ - [L] 414 415 # uploaded files 416 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; 417 418 if ( ! $subdomain_install ) 419 $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n"; 420 421 $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR] 422 RewriteCond %{REQUEST_FILENAME} -d 423 RewriteRule ^ - [L]'; 424 425 // @todo custom content dir. 426 if ( ! $subdomain_install ) 427 $htaccess_file .= "\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] 428 RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]'; 429 430 $htaccess_file .= "\nRewriteRule . index.php [L]"; 431 432 ?> 433 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 434 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>"> 435 <?php echo wp_htmledit_pre( $htaccess_file ); ?> 436 </textarea></li> 437 </ol> 438 <?php } 439 if ( !is_multisite() ) { ?> 356 440 <p><?php printf( __( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.') ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p> 357 441 <?php 358 442 } -
wp-includes/rewrite.php
1757 1757 1758 1758 if ( ! $this->using_permalinks() ) 1759 1759 return ''; 1760 1760 $rules = ''; 1761 $extra_indent = ''; 1762 if ( $add_parent_tags ) { 1763 $rules .= "<configuration>".$end_of_line; 1764 $rules .= $indent."<system.webServer>".$end_of_line; 1765 $rules .= $indent.$indent."<rewrite>".$end_of_line; 1766 $rules .= $indent.$indent.$indent."<rules>".$end_of_line; 1767 $extra_indent = $indent.$indent.$indent.$indent; 1768 } 1761 1769 if ( !is_multisite() ) { 1762 $rules = '';1763 $extra_indent = '';1764 1770 if ( $add_parent_tags ) { 1765 1771 $rules .= "<configuration>".$end_of_line; 1766 1772 $rules .= $indent."<system.webServer>".$end_of_line; … … 1778 1784 $rules .= $extra_indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line; 1779 1785 $rules .= $extra_indent."</rule>"; 1780 1786 1781 if ( $add_parent_tags ) {1782 $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line;1783 $rules .= $indent.$indent."</rewrite>".$end_of_line;1784 $rules .= $indent."</system.webServer>".$end_of_line;1785 $rules .= "</configuration>";1786 }1787 1787 } else { 1788 /* NOT SURE ABOUT THIS PORTION WHERE IT GOES IN Rules 1788 1789 $siteurl = get_option( 'siteurl' ); 1789 1790 $siteurl_len = strlen( $siteurl ); 1790 1791 if ( substr( WP_CONTENT_URL, 0, $siteurl_len ) == $siteurl && strlen( WP_CONTENT_URL ) > $siteurl_len ) 1791 1792 $content_path = substr( WP_CONTENT_URL, $siteurl_len + 1 ); 1792 1793 else 1793 1794 $content_path = 'wp-content'; 1794 $rules = '<rule name="wordpress - strip index.php" stopProcessing="false"> 1795 <match url="^index.php/(.*)$" /> 1796 <action type="Rewrite" url="{R:1}" /> 1797 </rule> 1798 <rule name="wordpress - 1" stopProcessing="true"> 1799 <match url="^(.*/)?files/$" /> 1800 <action type="Rewrite" url="index.php" /> 1801 </rule> 1802 <rule name="wordpress - 2" stopProcessing="true"> 1803 <match url="^(.*/)?files/(.*)" /> 1804 <conditions> 1805 <add input="{REQUEST_URI}" negate="true" pattern=".*' . $content_path . '/plugins.*"/> 1806 </conditions> 1807 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> 1808 </rule> 1809 <rule name="wordpress - 3" stopProcessing="true"> 1810 <match url="^(.+)$" /> 1811 <conditions> 1812 <add input="{REQUEST_URI}" pattern="^.*/wp-admin$" /> 1813 </conditions> 1814 <action type="Redirect" url="{R:1}/" redirectType="Permanent" /> 1815 </rule> 1816 <rule name="wordpress - 4" stopProcessing="true"> 1817 <match url="."/> 1818 <conditions logicalGrouping="MatchAny"> 1819 <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" /> 1820 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" /> 1821 </conditions> 1822 <action type="None" /> 1823 </rule> 1824 <rule name="wordpress - 5" stopProcessing="true"> 1825 <match url="^([_0-9a-zA-Z-]+/)?(wp-.*)" /> 1826 <action type="Rewrite" url="{R:2}" /> 1827 </rule> 1828 <rule name="wordpress - 6" stopProcessing="true"> 1829 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" /> 1830 <action type="Rewrite" url="{R:2}" /> 1831 </rule> 1832 <rule name="wordpress - 7" stopProcessing="true"> 1833 <match url="." /> 1834 <action type="Rewrite" url="index.php" /> 1835 </rule>'; 1795 */ 1796 if (is_subdomain_install()) { 1797 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 1\" stopProcessing=\"true\">".$end_of_line; 1798 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^index\.php$\" ignoreCase=\"false\" />".$end_of_line; 1799 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"None\" />".$end_of_line; 1800 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1801 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 2\" stopProcessing=\"true\">".$end_of_line; 1802 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^files/(.+)\" ignoreCase=\"false\" />".$end_of_line; 1803 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"wp-includes/ms-files.php?file={R:1}\" appendQueryString=\"false\" />".$end_of_line; 1804 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1805 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 3\" stopProcessing=\"true\">".$end_of_line; 1806 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^\" ignoreCase=\"false\" />".$end_of_line; 1807 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<conditions logicalGrouping=\"MatchAny\">".$end_of_line; 1808 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" ignoreCase=\"false\" />".$end_of_line; 1809 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" ignoreCase=\"false\" />".$end_of_line; 1810 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."</conditions>".$end_of_line; 1811 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"None\" />".$end_of_line; 1812 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1813 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 4\" stopProcessing=\"true\">".$end_of_line; 1814 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\".\" ignoreCase=\"false\" />".$end_of_line; 1815 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line; 1816 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1817 } else { 1818 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 1\" stopProcessing=\"true\">".$end_of_line; 1819 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^index\.php$\" ignoreCase=\"false\" />".$end_of_line; 1820 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"None\" />".$end_of_line; 1821 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1822 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 2\" stopProcessing=\"true\">".$end_of_line; 1823 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^([_0-9a-zA-Z-]+/)?files/(.+)\" ignoreCase=\"false\" />".$end_of_line; 1824 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"wp-includes/ms-files.php?file={R:2}\" appendQueryString=\"false\" />".$end_of_line; 1825 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1826 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 3\" stopProcessing=\"true\">".$end_of_line; 1827 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^([_0-9a-zA-Z-]+/)?wp-admin$\" ignoreCase=\"false\" />".$end_of_line; 1828 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Redirect\" url=\"{R:1}wp-admin/\" redirectType=\"Permanent\" />".$end_of_line; 1829 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1830 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 4\" stopProcessing=\"true\">".$end_of_line; 1831 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^\" ignoreCase=\"false\" />".$end_of_line; 1832 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<conditions logicalGrouping=\"MatchAny\">".$end_of_line; 1833 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" ignoreCase=\"false\" />".$end_of_line; 1834 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" ignoreCase=\"false\" />".$end_of_line; 1835 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."</conditions>".$end_of_line; 1836 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"None\" />".$end_of_line; 1837 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1838 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 5\" stopProcessing=\"true\">".$end_of_line; 1839 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)\" ignoreCase=\"false\" />".$end_of_line; 1840 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"{R:2}\" />".$end_of_line; 1841 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1842 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 6\" stopProcessing=\"true\">".$end_of_line; 1843 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\"^([_0-9a-zA-Z-]+/)?(.*\.php)$\" ignoreCase=\"false\" />".$end_of_line; 1844 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"{R:2}\" />".$end_of_line; 1845 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1846 $rules .= $extra_indent.$indent.$indent.$indent.$indent."<rule name=\"wordpress - Rule 7\" stopProcessing=\"true\">".$end_of_line; 1847 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<match url=\".\" ignoreCase=\"false\" />".$end_of_line; 1848 $rules .= $extra_indent.$indent.$indent.$indent.$indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line; 1849 $rules .= $extra_indent.$indent.$indent.$indent.$indent."</rule>".$end_of_line; 1850 } 1836 1851 } 1837 1852 if ( $add_parent_tags ) { 1853 $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line; 1854 $rules .= $indent.$indent."</rewrite>".$end_of_line; 1855 $rules .= $indent."</system.webServer>".$end_of_line; 1856 $rules .= "</configuration>"; 1857 } 1838 1858 $rules = apply_filters('iis7_url_rewrite_rules', $rules); 1839 1859 1840 1860 return $rules;