Make WordPress Core


Ignore:
Timestamp:
05/25/2010 05:12:47 AM (14 years ago)
Author:
wpmuguru
Message:

update rewrite rules for IIS, props Frumph, see #12758

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network.php

    r14845 r14871  
    337337</li>
    338338<?php
    339 // Construct an htaccess file.
    340 $htaccess_file = 'RewriteEngine On
    341 RewriteBase ' . $base . '
    342 RewriteRule ^index\.php$ - [L]
    343 
    344 # uploaded files
    345 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
    346 
    347 if ( ! $subdomain_install )
    348     $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
    349 
    350 $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
    351 RewriteCond %{REQUEST_FILENAME} -d
    352 RewriteRule ^ - [L]';
    353 
    354 // @todo custom content dir.
    355 if ( ! $subdomain_install )
    356     $htaccess_file .= "\n" . 'RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    357 RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]';
    358 
    359 $htaccess_file .= "\nRewriteRule . index.php [L]";
    360 
    361 ?>
    362             <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    363                 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
    364 <?php echo wp_htmledit_pre( $htaccess_file ); ?>
    365 </textarea></li>
     339    if (iis7_supports_permalinks()) {
     340            if (is_subdomain_install()) {
     341                $web_config_file =
     342'<?xml version="1.0" encoding="UTF-8"?>
     343<configuration>
     344    <system.webServer>
     345        <rewrite>
     346            <rules>
     347                <rule name="WordPress Rule 1" stopProcessing="true">
     348                    <match url="^index\.php$" ignoreCase="false" />
     349                    <action type="None" />
     350                </rule>
     351                <rule name="WordPress Rule 2" stopProcessing="true">
     352                    <match url="^files/(.+)" ignoreCase="false" />
     353                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
     354                </rule>
     355                <rule name="WordPress Rule 3" stopProcessing="true">
     356                    <match url="^" ignoreCase="false" />
     357                    <conditions logicalGrouping="MatchAny">
     358                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     359                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
     360                    </conditions>
     361                    <action type="None" />
     362                </rule>
     363                <rule name="WordPress Rule 4" stopProcessing="true">
     364                    <match url="." ignoreCase="false" />
     365                    <action type="Rewrite" url="index.php" />
     366                </rule>
     367            </rules>
     368        </rewrite>
     369    </system.webServer>
     370</configuration>';
     371            } else {
     372                $web_config_file =
     373'<?xml version="1.0" encoding="UTF-8"?>
     374<configuration>
     375    <system.webServer>
     376        <rewrite>
     377            <rules>
     378                <rule name="WordPress Rule 1" stopProcessing="true">
     379                    <match url="^index\.php$" ignoreCase="false" />
     380                    <action type="None" />
     381                </rule>
     382                <rule name="WordPress Rule 2" stopProcessing="true">
     383                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
     384                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
     385                </rule>
     386                <rule name="WordPress Rule 3" stopProcessing="true">
     387                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
     388                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
     389                </rule>
     390                <rule name="WordPress Rule 4" stopProcessing="true">
     391                    <match url="^" ignoreCase="false" />
     392                    <conditions logicalGrouping="MatchAny">
     393                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     394                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
     395                    </conditions>
     396                    <action type="None" />
     397                </rule>
     398                <rule name="WordPress Rule 5" stopProcessing="true">
     399                    <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
     400                    <action type="Rewrite" url="{R:2}" />
     401                </rule>
     402                <rule name="WordPress Rule 6" stopProcessing="true">
     403                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
     404                    <action type="Rewrite" url="{R:2}" />
     405                </rule>
     406                <rule name="WordPress Rule 7" stopProcessing="true">
     407                    <match url="." ignoreCase="false" />
     408                    <action type="Rewrite" url="index.php" />
     409                </rule>
     410            </rules>
     411        </rewrite>
     412    </system.webServer>
     413</configuration>';
     414            }
     415    ?>
     416        <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
     417        <textarea class="code" readonly="readonly" cols="100" rows="20">
     418        <?php echo wp_htmledit_pre( $web_config_file ); ?>
     419        </textarea></li>
    366420        </ol>
    367 <?php if ( !is_multisite() ) { ?>
     421    <?php } else {
     422        // Construct an htaccess file.
     423        $htaccess_file = 'RewriteEngine On
     424                RewriteBase ' . $base . '
     425                RewriteRule ^index\.php$ - [L]
     426               
     427                # uploaded files
     428                RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     429       
     430        if ( ! $subdomain_install )
     431            $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
     432       
     433        $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
     434                RewriteCond %{REQUEST_FILENAME} -d
     435                RewriteRule ^ - [L]';
     436       
     437        // @todo custom content dir.
     438        if ( ! $subdomain_install )
     439            $htaccess_file .= "\n" . 'RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
     440                    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]';
     441       
     442        $htaccess_file .= "\nRewriteRule . index.php [L]";
     443       
     444        ?>
     445        <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
     446        <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
     447        <?php echo wp_htmledit_pre( $htaccess_file ); ?>
     448        </textarea></li>
     449        </ol>
     450    <?php }
     451    if ( !is_multisite() ) { ?>
    368452        <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>
    369453<?php
Note: See TracChangeset for help on using the changeset viewer.