Ticket #18852: 18852.3.patch
File 18852.3.patch, 7.9 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/misc.php
19 19 } 20 20 21 21 /** 22 * Returns whether or not the server supports URL rewriting. 23 * 24 * @since 3.5 25 * 26 * @return bool Whether the server supports URL rewriting 27 */ 28 function got_url_rewrite() { 29 global $is_nginx; 30 $got_url_rewrite = ( got_mod_rewrite() or iis7_supports_permalinks() or $is_nginx ); 31 return apply_filters('got_url_rewrite', $got_url_rewrite); 32 } 33 34 /** 22 35 * {@internal Missing Short Description}} 23 36 * 24 37 * @since 1.5.0 -
wp-admin/network.php
314 314 * @since 3.0.0 315 315 */ 316 316 function network_step2( $errors = false ) { 317 global $base, $wpdb ;317 global $base, $wpdb, $is_nginx; 318 318 $hostname = get_clean_basedomain(); 319 319 320 320 if ( ! isset( $base ) ) … … 487 487 </textarea></li> 488 488 </ol> 489 489 490 <?php else : // end iis7_supports_permalinks(). construct an htaccess fileinstead:490 <?php elseif ( $is_nginx ) : // end iis7_supports_permalinks(). construct nginx configuration instead: 491 491 492 $nginx_config_file = "location / {\n"; 493 $nginx_config_file .= "\t" . 'try_files $uri $uri/ /index.php$is_args$args;' . "\n"; 494 $nginx_config_file .= "}\n\n"; 495 496 $nginx_config_file .= '# Uploaded files' . "\n"; 497 $nginx_config_file .= 'rewrite ^/' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) /wp-includes/ms-files.php?file=$2 last;' . "\n\n"; 498 499 if ( ! $subdomain_install ) { 500 $nginx_config_file .= '# Add trailing slash to /wp-admin' . "\n"; 501 $nginx_config_file .= 'rewrite /wp-admin$ $scheme://$host$uri/ permanent;' . "\n\n"; 502 $nginx_config_file .= 'if (!-e $request_filename) {' . "\n"; 503 $nginx_config_file .= "\t" . 'rewrite ^/[_0-9a-zA-Z-]+(/wp-(content|admin|includes).*) $1 last;' . "\n"; 504 $nginx_config_file .= "\t" . 'rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;' . "\n"; 505 $nginx_config_file .= "}\n"; 506 } 507 508 ?> 509 <li><p><?php _e( 'Add the following to your <code>nginx.conf</code> file (or equivalent), replacing other WordPress rules:' ); ?></p> 510 <textarea class="code" readonly="readonly" cols="100" rows="20"> 511 <?php echo esc_textarea( $nginx_config_file ); ?></textarea></li> 512 </ol> 513 514 <?php else : // end nginx. construct an htaccess file instead: 515 492 516 $htaccess_file = 'RewriteEngine On 493 517 RewriteBase ' . $base . ' 494 518 RewriteRule ^index\.php$ - [L] … … 515 539 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li> 516 540 </ol> 517 541 518 <?php endif; // end IIS/ Apache code branches.542 <?php endif; // end IIS/nginx/Apache code branches. 519 543 520 544 if ( !is_multisite() ) { ?> 521 545 <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> -
wp-admin/options-permalink.php
78 78 $iis7_permalinks = iis7_supports_permalinks(); 79 79 80 80 $prefix = $blog_prefix = ''; 81 if ( ! got_ mod_rewrite() && ! $iis7_permalinks)81 if ( ! got_url_rewrite() ) 82 82 $prefix = '/index.php'; 83 83 if ( is_multisite() && !is_subdomain_install() && is_main_site() ) 84 84 $blog_prefix = '/blog'; … … 128 128 $writable = true; 129 129 else 130 130 $writable = false; 131 } else if ( $is_nginx ) { 132 $writable = false; 131 133 } else { 132 134 if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') ) 133 135 $writable = true; … … 152 154 _e('Permalink structure updated. Remove write access on web.config file now!'); 153 155 else 154 156 _e('Permalink structure updated.'); 155 } else { 157 } else if ( $is_nginx ) { 158 if ( $permalink_structure ) 159 _e('Permalink structure updated. Ensure your nginx.conf file (or equivalent) contains the rewrite rules below.'); 160 else 161 _e('Permalink structure updated.'); 162 } else { 156 163 if ( $permalink_structure && ! $usingpi && ! $writable ) 157 164 _e('You should update your .htaccess now.'); 158 165 else … … 225 232 </table> 226 233 227 234 <h3><?php _e('Optional'); ?></h3> 228 <?php229 $suffix = '';230 if ( ! $is_apache && ! $iis7_permalinks )231 $suffix = 'index.php/';232 ?>233 235 <p><?php 234 /* translators: %s is a placeholder that must come at the start of the URL path. */235 printf( __('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code> http://example.org/%stopics/uncategorized/</code>. If you leave these blank the defaults will be used.'), $suffix); ?></p>236 /* translators: %s is the site URL. */ 237 printf( __('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.'), home_url( $prefix . $blog_prefix ) ); ?></p> 236 238 237 239 <table class="form-table"> 238 240 <tr> … … 269 271 <p><?php _e('If you temporarily make your site’s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.') ?></p> 270 272 <?php endif; ?> 271 273 <?php endif; ?> 274 <?php elseif ( $is_nginx ) : 275 if ( $permalink_structure && ! $usingpi ) : ?> 276 <p><?php _e('These are the rewrite rules you should have in your <code>nginx.conf</code> (or equivalent) file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> 277 <form action="options-permalink.php" method="post"> 278 <?php wp_nonce_field('update-permalink') ?> 279 <p><textarea rows="4" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->nginx_url_rewrite_rules() ); ?></textarea></p> 280 </form> 281 <?php endif; ?> 272 282 <?php else : 273 283 if ( $permalink_structure && ! $usingpi && ! $writable ) : ?> 274 284 <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> -
wp-includes/rewrite.php
1809 1809 } 1810 1810 1811 1811 /** 1812 * Retrieve Nginx formatted rewrite rules. 1813 * 1814 * @since 3.5 1815 * @access public 1816 * 1817 * @return string 1818 */ 1819 function nginx_url_rewrite_rules() { 1820 if ( ! $this->using_permalinks() ) 1821 return ''; 1822 1823 $rules = "location / {\n"; 1824 $rules .= "\t" . 'try_files $uri $uri/ /index.php$is_args$args;' . "\n"; 1825 $rules .= "}\n"; 1826 1827 $rules = apply_filters('nginx_rewrite_rules', $rules); 1828 1829 return $rules; 1830 } 1831 1832 /** 1812 1833 * Add a straight rewrite rule. 1813 1834 * 1814 1835 * Any value in the $after parameter that isn't 'bottom' will be placed at -
wp-includes/vars.php
87 87 $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false); 88 88 89 89 /** 90 * Whether the server software is Nginx or something else 91 * @global bool $is_nginx 92 */ 93 $is_nginx = (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false); 94 95 /** 90 96 * Whether the server software is IIS or something else 91 97 * @global bool $is_IIS 92 98 */