Make WordPress Core


Ignore:
Timestamp:
09/11/2012 10:22:20 PM (12 years ago)
Author:
nacin
Message:

Remove ms-files.php rewriting from WordPress multisite. fixes #19235.

Keep existing networks compatible with a ms_files_rewriting network option.

File:
1 edited

Legend:

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

    r19956 r21823  
    107107    '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
    108108    '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
    109     '<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
     109    '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
    110110    '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' .
    111111    '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed in a future version.') . '</p>' .
     
    190190        $error_codes = $errors->get_error_codes();
    191191    }
    192 
    193     if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    194         echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
    195192
    196193    $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
     
    236233    endif;
    237234
     235        if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
     236            echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
     237
    238238        $is_www = ( 0 === strpos( $hostname, 'www.' ) );
    239239        if ( $is_www ) :
     
    361361?>
    362362        <ol>
    363             <li><p><?php
    364                 printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
    365                 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    366                     echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
    367             ?></p></li>
    368363            <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
    369364                <textarea class="code" readonly="readonly" cols="100" rows="7">
     
    416411                    <match url="^index\.php$" ignoreCase="false" />
    417412                    <action type="None" />
    418                 </rule>
    419                 <rule name="WordPress Rule 2" stopProcessing="true">
     413                </rule>';
     414                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     415                    $web_config_file .= '
     416                <rule name="WordPress Rule for Files" stopProcessing="true">
    420417                    <match url="^files/(.+)" ignoreCase="false" />
    421418                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    422                 </rule>
    423                 <rule name="WordPress Rule 3" stopProcessing="true">
     419                </rule>';
     420                }
     421                $web_config_file .= '
     422                <rule name="WordPress Rule 2" stopProcessing="true">
    424423                    <match url="^" ignoreCase="false" />
    425424                    <conditions logicalGrouping="MatchAny">
     
    429428                    <action type="None" />
    430429                </rule>
    431                 <rule name="WordPress Rule 4" stopProcessing="true">
     430                <rule name="WordPress Rule 3" stopProcessing="true">
    432431                    <match url="." ignoreCase="false" />
    433432                    <action type="Rewrite" url="index.php" />
     
    447446                    <match url="^index\.php$" ignoreCase="false" />
    448447                    <action type="None" />
    449                 </rule>
     448                </rule>';
     449                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     450                    $web_config_file .= '
     451                <rule name="WordPress Rule for Files" stopProcessing="true">
     452                    <match url="^files/(.+)" ignoreCase="false" />
     453                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
     454                </rule>';
     455                }
     456                $web_config_file .= '
    450457                <rule name="WordPress Rule 2" stopProcessing="true">
    451                     <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
    452                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
    453                 </rule>
    454                 <rule name="WordPress Rule 3" stopProcessing="true">
    455458                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    456459                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    457460                </rule>
    458                 <rule name="WordPress Rule 4" stopProcessing="true">
     461                <rule name="WordPress Rule 3" stopProcessing="true">
    459462                    <match url="^" ignoreCase="false" />
    460463                    <conditions logicalGrouping="MatchAny">
     
    464467                    <action type="None" />
    465468                </rule>
    466                 <rule name="WordPress Rule 5" stopProcessing="true">
     469                <rule name="WordPress Rule 4" stopProcessing="true">
    467470                    <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
    468471                    <action type="Rewrite" url="{R:1}" />
    469472                </rule>
    470                 <rule name="WordPress Rule 6" stopProcessing="true">
     473                <rule name="WordPress Rule 5" stopProcessing="true">
    471474                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    472475                    <action type="Rewrite" url="{R:2}" />
    473476                </rule>
    474                 <rule name="WordPress Rule 7" stopProcessing="true">
     477                <rule name="WordPress Rule 6" stopProcessing="true">
    475478                    <match url="." ignoreCase="false" />
    476479                    <action type="Rewrite" url="index.php" />
     
    483486    ?>
    484487        <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    485         <textarea class="code" readonly="readonly" cols="100" rows="20">
    486         <?php echo esc_textarea( $web_config_file ); ?>
     488        <?php
     489        if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
     490            echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     491        ?>
     492        <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
    487493        </textarea></li>
    488494        </ol>
     
    492498        $htaccess_file = 'RewriteEngine On
    493499RewriteBase ' . $base . '
    494 RewriteRule ^index\.php$ - [L]
    495 
    496 # uploaded files
    497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     500RewriteRule ^index\.php$ - [L]' . "\n";
     501
     502        if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     503            $htaccess_file .= "\n# uploaded files\nRewriteRule ^";
     504            $htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     505        }
    498506
    499507        if ( ! $subdomain_install )
     
    512520        ?>
    513521        <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    514         <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
     522        <?php
     523        if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
     524            echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     525        ?>
     526        <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
    515527<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
    516528        </ol>
Note: See TracChangeset for help on using the changeset viewer.