Add nginx detection to the Permalink Settings screen.

Introduces got_url_rewrite() and a corresponding filter, which should now be used in lieu of the got_rewrite filter in got_mod_rewrite().

This does not write or even suggest nginx configuration; rather, it prevents nginx from being considered as either Apache or as an unrecognized server.

props johnbillion.
fixes #25098.


git-svn-id: https://develop.svn.wordpress.org/trunk@25456 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-09-16 20:06:27 +00:00
parent 17c772d95b
commit c89f2e38a8
3 changed files with 50 additions and 7 deletions

View File

@@ -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(
<h3 class="title"><?php _e('Optional'); ?></h3>
<?php
$suffix = '';
if ( ! $is_apache && ! $iis7_permalinks )
$suffix = $wp_rewrite->index . '/';
$suffix = $prefix;
if ( $suffix )
$suffix = ltrim( $suffix, '/' ) . '/';
?>
<p><?php
/* translators: %s is a placeholder that must come at the start of the URL path. */
@@ -269,7 +273,7 @@ printf( __('If you like, you may enter custom structures for your category and t
<p><?php _e('If you temporarily make your site&#8217;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>
<?php endif; ?>
<?php endif; ?>
<?php else :
<?php elseif ( ! $is_nginx ) :
if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
<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&#8217;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>
<form action="options-permalink.php" method="post">