mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
Support IIS 7.0 URL Rewrite Module. Props ruslany. Hat tips to peaceablewhale, hakre, Denis-de-Bernardy, sivel. fixes #8974
git-svn-id: https://develop.svn.wordpress.org/trunk@11350 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -70,6 +70,7 @@ add_filter('admin_head', 'add_js');
|
||||
include('admin-header.php');
|
||||
|
||||
$home_path = get_home_path();
|
||||
$iis7_permalinks = iis7_supports_permalinks();
|
||||
|
||||
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
|
||||
check_admin_referer('update-permalink');
|
||||
@@ -100,12 +101,19 @@ $permalink_structure = get_option('permalink_structure');
|
||||
$category_base = get_option('category_base');
|
||||
$tag_base = get_option( 'tag_base' );
|
||||
|
||||
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
|
||||
$writable = true;
|
||||
else
|
||||
$writable = false;
|
||||
if ( $iis7_permalinks ) {
|
||||
if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
|
||||
$writable = true;
|
||||
else
|
||||
$writable = false;
|
||||
} else {
|
||||
if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
|
||||
$writable = true;
|
||||
else
|
||||
$writable = false;
|
||||
}
|
||||
|
||||
if ($wp_rewrite->using_index_permalinks())
|
||||
if ( $wp_rewrite->using_index_permalinks() )
|
||||
$usingpi = true;
|
||||
else
|
||||
$usingpi = false;
|
||||
@@ -115,11 +123,21 @@ $wp_rewrite->flush_rules();
|
||||
|
||||
<?php if (isset($_POST['submit'])) : ?>
|
||||
<div id="message" class="updated fade"><p><?php
|
||||
if ( $permalink_structure && !$usingpi && !$writable )
|
||||
_e('You should update your .htaccess now.');
|
||||
else
|
||||
_e('Permalink structure updated.');
|
||||
?></p></div>
|
||||
if ( $iis7_permalinks ) {
|
||||
if ( $permalink_structure && ! $usingpi && ! $writable )
|
||||
_e('You should update your web.config now');
|
||||
else if ( $permalink_structure && ! $usingpi && $writable)
|
||||
_e('Permalink structure updated. Remove write access on web.config file now!');
|
||||
else
|
||||
_e('Permalink structure updated');
|
||||
} else {
|
||||
if ( $permalink_structure && ! $usingpi && ! $writable )
|
||||
_e('You should update your .htaccess now.');
|
||||
else
|
||||
_e('Permalink structure updated.');
|
||||
}
|
||||
?>
|
||||
</p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wrap">
|
||||
@@ -134,7 +152,7 @@ else
|
||||
<?php
|
||||
$prefix = '';
|
||||
|
||||
if ( ! got_mod_rewrite() )
|
||||
if ( ! got_mod_rewrite() && ! $iis7_permalinks )
|
||||
$prefix = '/index.php';
|
||||
|
||||
$structures = array(
|
||||
@@ -179,7 +197,7 @@ $structures = array(
|
||||
</table>
|
||||
|
||||
<h3><?php _e('Optional'); ?></h3>
|
||||
<?php if ($is_apache) : ?>
|
||||
<?php if ( $is_apache || $iis7_permalinks ) : ?>
|
||||
<p><?php _e('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 <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
|
||||
<?php else : ?>
|
||||
<p><?php _e('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/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
|
||||
@@ -203,12 +221,23 @@ $structures = array(
|
||||
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?php 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’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>
|
||||
<?php if ($iis7_permalinks) :
|
||||
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : ?>
|
||||
<p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p>
|
||||
<form action="options-permalink.php" method="post">
|
||||
<?php wp_nonce_field('update-permalink') ?>
|
||||
<p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo wp_specialchars($wp_rewrite->iis7_url_rewrite_rules()); ?></textarea></p>
|
||||
</form>
|
||||
<p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p>
|
||||
<?php endif; ?>
|
||||
<?php else :
|
||||
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’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">
|
||||
<?php wp_nonce_field('update-permalink') ?>
|
||||
<p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user