WordPress.org

Make WordPress Core

Opened 9 years ago

Last modified 3 years ago

#10425 assigned enhancement

Improvements to IIS7 Rewriting Code

Reported by: bforchhammer Owned by:
Milestone: Future Release Priority: low
Severity: normal Version: 2.8.1
Component: Permalinks Keywords: has-patch dev-feedback needs-refresh
Focuses: Cc:

Description

#8974 introduced a set of functions and changes which allow to automatically generate Rewrite Rules for Wordpress installs running on IIS7.

There are some issues with that implementation that I think are worth being written down and discussed somewhere so here we go:

1) There's no "Verbose" option for IIS rules; while I can't say when it would make sense to have a verbose listing of all WordPress rewrite rules in .htaccess/web.config it might be something that should be available for both systems?

2) IIS does not add non wordpress rules ($non_wp_rules) to the web.config file (iis7_url_rewrite_rules()) which means that any custom rewriting which plugins/users can do on apache don't work on IIS.

3) At the moment it's assumed that there is only ONE single rule needed for IIS. Especially when looking at the merge with WPMU this is going to become a problem because WPMU uses multiple rules. Every rule has to have a unique name and functions like iis7_rewrite_rule_exists() and iis7_delete_rewrite_rule() only look for one rule with name "wordpress". Custom Rules (see 2) also won't work without a change here. For a partial fix see misc.php in Patch on MU #991)

Any comments?

Attachments (1)

10425.patch (6.3 KB) - added by ruslany 9 years ago.
Patch for the $non_wp_rules support

Download all attachments as: .zip

Change History (15)

#1 @ruslany
9 years ago

  • Cc ruslany@… added

1) Does the verbose rules options ever get used? It looks like in the rewrite.php file it is hardcoded to be off.

2) I'll need to better understand how non_wp_rules work. Do you have an example of such rule? Or may be a plugin that uses those rules.

3) This should be fixed. I'll try to spend some time on preparing a patch for this.

#2 @peaceablewhale
9 years ago

  1. What is the use of the Verbose option?
  1. I think a plugin can add non-WordPress rules via the iis7_url_rewrite_rules filter. The $non_wp_rules was designed for Apache mod_rewrite and those rules cannot be used in IIS.
  1. It looks like using starts-with(@name,'wordpress') is good solution.

#3 follow-up: @ruslany
9 years ago

After more investigation I do not think that support for verbose rules should be added to IIS specific code. It is still not clear to me whether verbose rules option is ever used. Manually enabling it on Apache causes WP to generate about 70 mod_rewrite rules in .htaccess file. I do not understand why it is needed, as the only rule that is required for pretty permalinks to work is the rule to rewrite everything to index.php. In addition to that, having so many rules in either .htaccess file or in web.config file may degrade the performance of the web server.

#4 @peaceablewhale
9 years ago

  • Keywords reporter-feedback close added

#5 in reply to: ↑ 3 @bforchhammer
9 years ago

  • Keywords reporter-feedback close removed

Replying to ruslany:

After more investigation I do not think that support for verbose rules should be added to IIS specific code. It is still not clear to me whether verbose rules option is ever used. Manually enabling it on Apache causes WP to generate about 70 mod_rewrite rules in .htaccess file. I do not understand why it is needed, as the only rule that is required for pretty permalinks to work is the rule to rewrite everything to index.php. In addition to that, having so many rules in either .htaccess file or in web.config file may degrade the performance of the web server.

I agree that it does not seem to make much sense; maybe the option for "verbose rules" should just be removed completely then? (clean-up?)

2) I'll need to better understand how non_wp_rules work. Do you have an example of such rule? Or may be a plugin that uses those rules.

No, I don't know if anyone actually uses it; I only stumbled on it myself when writing the patch for MU #991. It was introduced with the initial patch in #2433/[3638] (Dez 2006) and has not been touched since.

#6 @bforchhammer
9 years ago

I just stumbled on another issue that should be considered when/if someone starts work on this issue.

WP SuperCache uses the .htaccess file to enable things like "gzip compression". I think it might be possible to do a similiar thing on IIS (see config value httpCompression). Adding these config values would of course be the job of WP SuperCache but the core functions would need to provide support for adding arbitrary config values. At the moment only "rewrite rules" are possible as far as I know.

#7 follow-up: @ruslany
9 years ago

Are there any core functions in WP that WP Super Cache uses to write arbitrary configuration settings into .htaccess file? If there is none then I do not think there is a need to add any functions for generic IIS config management. As was mentioned already, it should be responsibility of the WP Super Cache to write any new config settings into the IIS config file.

#8 @westi
9 years ago

  • Cc westi added

#9 in reply to: ↑ 7 @westi
9 years ago

Replying to ruslany:

Are there any core functions in WP that WP Super Cache uses to write arbitrary configuration settings into .htaccess file? If there is none then I do not think there is a need to add any functions for generic IIS config management. As was mentioned already, it should be responsibility of the WP Super Cache to write any new config settings into the IIS config file.

WP Super Cache will be using the mod_rewrite_rules filter to add extra rules to the .htaccess file.

For the IIS7 style rewrites we have the iis7_url_rewrite_rules filter where SuperCache could add the extra rules.

As for the Verbose Rules that is a different issue.

If you look at the WP_Rewrite::mod_rewrite_rules function you will see a block or code wrapped in a check for if ($this->use_verbose_rules) this code block is triggered if someone manually enables it and writes out all the rules as individual mod_rewrite rules instead of using the internal rewriter - not sure if this can be automated for IIS7?

Is does look like support for the $non_wp_rules in IIS7 would be nice if possible.

@ruslany
9 years ago

Patch for the $non_wp_rules support

#10 @ruslany
9 years ago

There are now several patches submitted for the IIS URL rewriting code. I would recommend to apply them in the following order:

  1. Apply the patch #10384
  2. Update and then apply the patch #10386
  3. Finally, update and then apply the patch for this ticket

#11 @edwardw
7 years ago

  • Keywords has-patch dev-feedback added

Two-year refresh. Core devs and bug reporters: Is this bug still relevant? If it is, could you guys please take some action on this bug.

#12 @knutsp
7 years ago

  • Cc knut@… added

#13 @ryan
4 years ago

  • Owner ryan deleted
  • Status changed from new to assigned

#14 @chriscct7
3 years ago

  • Keywords needs-refresh added
Note: See TracTickets for help on using tickets.