diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 5b609e45ba..13382754e7 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -7,17 +7,50 @@ */ /** - * {@internal Missing Short Description}} + * Returns whether the server is running Apache with the mod_rewrite module loaded. * * @since 2.0.0 * - * @return unknown + * @return bool */ function got_mod_rewrite() { $got_rewrite = apache_mod_loaded('mod_rewrite', true); + + /** + * Filter whether Apache and mod_rewrite are present. + * + * This filter was previously used to force URL rewriting for other servers, + * like nginx. Use the got_url_rewrite filter in got_url_rewrite() instead. + * + * @see got_url_rewrite() + * + * @since 2.5.0 + * @param bool $got_rewrite Whether Apache and mod_rewrite are present. + */ return apply_filters('got_rewrite', $got_rewrite); } +/** + * Returns whether the server supports URL rewriting. + * + * Detects Apache's mod_rewrite, IIS 7.0+ permalink support, and nginx. + * + * @since 3.7.0 + * + * @return bool Whether the server supports URL rewriting. + */ +function got_url_rewrite() { + $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() ); + + /** + * Filter whether URL rewriting is available. + * + * @since 3.7.0 + * @param bool $got_url_rewrite Whether URL rewriting is available. + */ + return apply_filters( 'got_url_rewrite', $got_url_rewrite ); +} + /** * {@internal Missing Short Description}} * diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index e045982b28..d8d454cdb6 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -75,7 +75,7 @@ $home_path = get_home_path(); $iis7_permalinks = iis7_supports_permalinks(); $prefix = $blog_prefix = ''; -if ( ! got_mod_rewrite() && ! $iis7_permalinks ) +if ( ! got_url_rewrite() ) $prefix = '/index.php'; if ( is_multisite() && !is_subdomain_install() && is_main_site() ) $blog_prefix = '/blog'; @@ -126,6 +126,8 @@ if ( $iis7_permalinks ) { $writable = true; else $writable = false; +} elseif ( $is_nginx ) { + $writable = false; } else { if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') ) $writable = true; @@ -152,6 +154,8 @@ if ( ! is_multisite() ) { _e('Permalink structure updated. Remove write access on web.config file now!'); else _e('Permalink structure updated.'); + } elseif ( $is_nginx ) { + _e('Permalink structure updated.'); } else { if ( $permalink_structure && ! $usingpi && ! $writable ) _e('You should update your .htaccess now.'); @@ -226,9 +230,9 @@ $structures = array(
index . '/'; +$suffix = $prefix; +if ( $suffix ) + $suffix = ltrim( $suffix, '/' ) . '/'; ?>web.config file automatically, do not forget to revert the permissions after the file has been created.') ?>
-.htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess
file. Click in the field and press CTRL + a to select all.') ?>