IIS 7 URL Rewrite Module support in WordPress 2.8
I am pleased to let everyone know that WordPress development community has added a built-in support for IIS 7 URL Rewrite Module in the upcoming WordPress 2.8 release. Starting with version 2.8 the Permalink Settings page will allow you to easily configure “Pretty Permalinks” URL structure when WordPress is running on IIS 7 with URL Rewrite Module v1.1 installed.
Here is how the process of updating Permalinks structure will look like in WordPress 2.8 on IIS 7:
- Go to Settings –> Permalinks page and choose the permalink structure that you prefer:

- After clicking on “Save Changes” button the generated rewrite rule will be displayed with the instructions on how to update the web.config file manually:

- Now you can copy the the given XML and put it into the web.config file inside of /<configuration>/<system.webServer>/<rewrite>/<rules> element and that’s it!
- Alternatively – instead of manually editing the web.config file you can have WordPress to update it automatically for you. To do that, temporarily grant WordPress write access to web.config file and click on “Save Changes” again. WordPress will add its rewrite rule into the proper location inside of the web.config file. Do not forget to revert the write permission on web.config file after the rule has been saved.
If you want to try this functionality, as well as all the other new features in the upcoming WordPress 2.8 release, you can download the latest nightly build. Also, pretty soon the 2.8 beta will be available.
Thanks to the WordPress development community for adding this functionality! Specifically, big thanks to peaceablewhale, Denis-de-Bernardy, hakre, sivel and ryan for directly working on the patch and contributing to it in many different ways: testing, code reviewing, cleaning up the code and checking it in.
6,780 views
ruslany on May 15th 2009 in PHP, URLRewrite, WordPress

Hi, I need to add this rules for wordpress,
RewriteRule /tag/(.*) /index\.php\?tag=$1,but it’s used on helicontech’s software.I tried import in iis7 rewrite-module but it does’t work! Can you help me change the rule to iis7? Thanks a lot!you will need to remove the slash at the beginning of the pattern. Also the substution url in your rule looks incorrect. Try this:
<rule name=”somerule”>
<match url=”tag/(.*)” />
<action type=”Rewrite” url=”index.php?tag=$1″ />
</rule>
Hello, we hav install WordPress 2.8 beta2 on IIS 7 with URL Rewrite Module v1.1, but we have no Code under the “Save Changes” button. We have write the code from your screen in the web.config but also a 500 Mistake. Sry my eglish issent good.
Sayuri, is IIS configured to run PHP via FastCGI? The WordPress will offer the pretty permalinks option only if PHP is running via FastCGI.
Also, when WordPress shows the permalink options, do they contain “index.php”?
Hi-
We are working on permalinks – and I have same issue as Sayuri. How do we check to see if PHP is running on FastCGI. I think it is but not sure how to confirm.
Thanks you for posting this information about WP and IIS7!
Andrea,
There are three conditions that need to be true in order for WordPress 2.8 to offer pretty permalinks on IIS7:
1. PHP is running via FastCGI
2. PHP version 5 is used
3. URL Rewrite Module 1.1 is installed and enabled.
If any of those is not true then WordPress will work as in previous versions and will offer “Almost Pretty Permalinks” option.
To check if FastCGI is used, call phpinfo() function and check the “Server API”. It should say “CGI/FastCGI”. Alternatively, call php_sapi_name() function. It should return ‘cgi-fcgi’.
Please let me know if you see all three conditions to be true and permalinks still do not work. I will investigate further.
Thanks for the extra info – we manually edited the cgi.config file and made it match what shows in your step #2 above.
it’s working now. Thank you.
Andrea, did WordPress show you the rewrite rule with the instructions text as shown in screenshot for step #2?
[...] http://ruslany.net/2009/05/iis-7-url-rewrite-module-support-in-wordpress-28/ [...]
I am getting a fraking error on every page, every update of every field on the site since I upgraded to 2.8 iis. It is making me consider downgrading wordpress. I would appreciate any light on this issue:
PHP Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(C:\SITES\HypeScience.com\www/C:\SITES\HypeScience.com\www/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack-en_US.mo) is not within the allowed path(s): (C:\SITES) in C:\SITES\HypeScience.com\www\wp-includes\l10n.php on line 324Celso, thanks for reporting this. Looks like this is a bug in the plugin. It incorreclty passes an argument to a function load_plugin_textdomain, which causes the open_basedir warning.
You can work around it by changing the init function in all_in_one_seo_pack.php file to look like this:
function init() {
if (function_exists('load_plugin_textdomain'))
load_plugin_textdomain('all_in_one_seo_pack', false, 'all-in-one-seo-pack');
}
Note that after you change this you may run into another bug that only shows up with open_basedir enabled – http://core.trac.wordpress.org/ticket/10132. That one will be fixed in 2.8.1.
Thanks man. I rolled back the plugin and things got better. But i am getting the open_basedir enabled. Will wait until the next until 281.
The all-in-one-seo-pack plugin author has been informed of this bug and will look into fixing it in next plugin update.
Unfortunately the 2.8.1 release of wordpress only allows a single rule to be manipulated into the web.config and not multiple rules as such is needed for WPMU and future rules as needed.
Hopefully an update that loops through listed rulesets will fix this in a future patch.
- Phil
The patch for WPMU 2.8 has been provided and it should be fixed in future releases of WPMU.
hi…
recently i setup wordpress 2.8 with on IIS 7 with fastCGI and Rewrite Module is installed.
I am not seeing any code section as in screeshot #2, i want to have a url with out index.php so i setup custom structure to “/%year%/%monthnum%/%day%/%postname%/” but the links are not working.
Can you please guide me in fixing this issue.
Vijay, please check the conditions described in this comment and let me know what you find.
Great module – thanks so much! 2 questions.
1. Your rewrite rule is different than the one created by WordPress. Is there a difference in performance or behavior between the two?
2. I’d like to have anyone who navigates using index.php receive a permanent redirect to the URL without the index.php. Is there a way to do that?
Here are my versions:
- Windows Server 2008 R2
- URL Rewrite Module v2.0 RC
- PHP 5.3.0
- WordPress 2.8.5
Thanks,
David
@David:
1. No, there is no difference in performance. URL rewrite module caches the rewrite rules logic, so it does not matter if wildcard or regex is used for the rule. The wordpress rule uses wildcard patterns, because it is simpler.
2. It is relatively easy to do. Just create a redirect rule that has pattern “^index\.php” and then redirects to “/”. Place this rule before the rewrite rule generated by the wordpress.
Hello Ruslany , i am in deep trouble . pls help me
I am getting this error on my blog’s homepage header and also i am unable to login to my admin panel
Below are the errors i am getting in my blog
1. On the Header :
“Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-content/plugins/index.php/languages/index-en_US.mo) is not within the allowed path(s): (/customers/gupshupblog.com/gupshupblog.com:/tmp:/var/www/diagnostics:/usr/share/php) in /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/l10n.php on line 329″
And this error i recive when i try to login to my admin panel
Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-content/plugins/index.php/languages/index-en_US.mo) is not within the allowed path(s): (/customers/gupshupblog.com/gupshupblog.com:/tmp:/var/www/diagnostics:/usr/share/php) in /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/l10n.php on line 329
Warning: Cannot modify header information – headers already sent by (output started at /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/l10n.php:329) in /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/functions.php on line 790
Warning: Cannot modify header information – headers already sent by (output started at /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/l10n.php:329) in /customers/gupshupblog.com/gupshupblog.com/httpd.www/wp-includes/functions.php on line 791
So pls help me out in resolving this ???
Sunil, can you open the php.ini file used by your PHP installation and check what is the value specified for the open_basedir directive? I suspect that it may have been specified incorrectly. The paths should be separated by “;”, but in your case it looks like they are separated by “:”.
I am getting a 404 error on all my posts after implementing this change. Do you know why that might be? I meet all the requirements
php 5.2.9
iis 7
url rewrite 2.0
I set the proper permissions and let WP modify my web.config the rule got created ok and everything works on the site EXCEPT for posts.
Hi Ruslan,
I am trying to redirect all of my blogengine like urls to my wordpress blog but struggling to accomplish this task. Please help!
blogengine url format: http://www.mydomain.com/post/2010/02/07/this-is-the-post-title.aspx
wordpress url: http://www.mydomain.com/2010/02/07/this-is-the-post-title/
I’ve added a new rule along with the wordpress rule for some reason i am getting the old 404 error when I try the blogengine url format.
The site is hosted on ISS7 and PHP5 (godaddy windows shared hosting)
please have a look at my web.config and let me know if i am doing anything wrong:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect(301) all legacy BlogEngine posts">
<match url="(/20[0-9][0-9]/\d{2}/\d{2}/)(.*).aspx" />
<action type="Rewrite" url="{R:0}{R:1}/" />
</rule>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Please Note: the wordpress rewrite works fine.
@a43: This is most probably because the pattern for the redirect rule is incorrect. Try this rule instead:
<rules>
<rule name="Redirect(301) all legacy BlogEngine posts">
<match url="^post/(20[0-9][0-9]/\d{2}/\d{2}/)(.*).aspx" />
<action type="Rewrite" url="{R:1}{R:2}/" />
</rule>
Ruslan, thanks for the reply.
I did try your rule unfortunately it didn’t work, still getting the 404 error.
after loads of googling and “trail and error” managed to get the following rule to work on my environment:
<rule name="Redirect(301) all legacy BlogEngine posts" stopProcessing="true">
<match url=".aspx" />
<conditions>
<add input="{HTTP_URL}" negate="false" pattern="(/20[0-9][0-9]/\d{2}/\d{2}/)(.*)\.aspx" />
</conditions>
<action type="Redirect" url="{C:1}{C:2}/" redirectType="Permanent" />
</rule>
can you see any differences? I still can’t understand why your suggested rule didn’t work.
My rule did not work because its pattern starts with ^post. It looks like your URLs do not actually start with /post, so if you modify the rule pattern to be “(20[0-9][0-9]/\d{2}/\d{2}/)(.*).aspx$” then it should work. Note that it is important to not have the “/” at the beginning of the pattern.
Thanks Ruslan
Hi,
I have tried to apply it on my site, which runs on IIS 7, unfortunately it seems to be working only when the page slug is written in english.
When I try to click on a page where the slug is in hebrew letters such as פרופיל (Profile) it goes to my custom 404 page.
Is there any solution for this? Thank you.
@Shir: there is a known issue in IIS 7 FastCGI module in how it handles the REQUEST_URI server variable for non-ascii characters. IIS team is planning to provide an update for it soon.
Meanwhile you can use this workaround:
In the wp-config.php file add this code:
if (isset($_SERVER['UNENCODED_URL']))
$_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
Hi, Thank you for your reply… but it doesn’t seems to work …
Thanks, I guess we will just have to wait for it to be solved.
my wordpress is installed in a subfolder (blog.domain.com)
how do we know that URL Rewrite Module 1.1 is installed and enabled?
i try to add the rewrite code in the web.config but i receive error 500.. may i know how to solve?
If you try to add the rewrite rule and get error 500 then most probably the url rewrite module is not installed. You can check if it is installed and enabled by using this code in PHP script:
< ?php
if (isset($_SERVER['IIS_UrlRewriteModule']))
echo 'URL Rewrite Module is installed';
else
echo 'URL Rewrite Module is not installed';
?>
I have installed a Windows 2008 Server R2 and I have installed WordPress via the “Web App Gallery”.
When trying to change the permalinks settings in the WP admin panel, I see the XML code I should enter in the web.config file.
The web.config in the root of the webserver only contains the values that WP suggested.
When I go to a individual post on the WP website, I get an IIS7 404 error page …
How can I check what version of URL rewrite and all the other things (PHP? FastCGI?) I have installed?
Hello ruslany please help me i have wordpress 3.0 with iis7 my url rewriting not working . all url come with /index.php/ . how to remove this . and also 404 not working plese help me?
Is there any solution for this? Thank you.
Hi Arif, How did you install WordPress and which URL rewrite module do you use?
Hello Sir,
Thanx for you support , i have normally uploaded and installed WordPress 3.0 and actually i have iis6 . and my host provider said me that he don’t know about URL rewrite module . So please tell me is there any solution which is done by my side only . Thanx ones again .
Hi Arif,
The URL Rewrite Module is not supported for IIS 6. You may want to ask your hosting provider if they would consider installing a third party URL Rewriting solutions on their servers, e.g. ISAPI_Rewrite.