Make WordPress Core


Ignore:
Timestamp:
05/16/2009 02:04:36 AM (16 years ago)
Author:
ryan
Message:

Support IIS 7.0 URL Rewrite Module. Props ruslany. Hat tips to peaceablewhale, hakre, Denis-de-Bernardy, sivel. fixes #8974

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r11204 r11350  
    7171
    7272$home_path = get_home_path();
     73$iis7_permalinks = iis7_supports_permalinks();
    7374
    7475if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
     
    101102$tag_base = get_option( 'tag_base' );
    102103
    103 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
    104     $writable = true;
    105 else
    106     $writable = false;
    107 
    108 if ($wp_rewrite->using_index_permalinks())
     104if ( $iis7_permalinks ) {
     105    if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
     106        $writable = true;
     107    else
     108        $writable = false;
     109} else {
     110    if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
     111        $writable = true;
     112    else
     113        $writable = false;
     114}
     115
     116if ( $wp_rewrite->using_index_permalinks() )
    109117    $usingpi = true;
    110118else
     
    116124<?php if (isset($_POST['submit'])) : ?>
    117125<div id="message" class="updated fade"><p><?php
    118 if ( $permalink_structure && !$usingpi && !$writable )
    119     _e('You should update your .htaccess now.');
    120 else
    121     _e('Permalink structure updated.');
    122 ?></p></div>
     126if ( $iis7_permalinks ) {
     127    if ( $permalink_structure && ! $usingpi && ! $writable )
     128        _e('You should update your web.config now');
     129    else if ( $permalink_structure && ! $usingpi && $writable)
     130        _e('Permalink structure updated. Remove write access on web.config file now!');
     131    else
     132        _e('Permalink structure updated');
     133} else {
     134    if ( $permalink_structure && ! $usingpi && ! $writable )
     135        _e('You should update your .htaccess now.');
     136    else
     137        _e('Permalink structure updated.');
     138}
     139?>
     140</p></div>
    123141<?php endif; ?>
    124142
     
    135153$prefix = '';
    136154
    137 if ( ! got_mod_rewrite() )
     155if ( ! got_mod_rewrite() && ! $iis7_permalinks )
    138156    $prefix = '/index.php';
    139157
     
    180198
    181199<h3><?php _e('Optional'); ?></h3>
    182 <?php if ($is_apache) : ?>
     200<?php if ( $is_apache || $iis7_permalinks ) : ?>
    183201    <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>
    184202<?php else : ?>
     
    204222</p>
    205223  </form>
    206 <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
    207   <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>
     224<?php if ($iis7_permalinks) :
     225    if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : ?>
     226<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&#8217;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>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.') ?></p>
     227<form action="options-permalink.php" method="post">
     228<?php wp_nonce_field('update-permalink') ?>
     229    <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>
     230</form>
     231<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> 
     232    <?php endif; ?>
     233<?php else :
     234    if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
     235<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>
    208236<form action="options-permalink.php" method="post">
    209237<?php wp_nonce_field('update-permalink') ?>
    210238    <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>
    211239</form>
     240    <?php endif; ?>
    212241<?php endif; ?>
    213242
Note: See TracChangeset for help on using the changeset viewer.