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:

  1. Go to Settings –> Permalinks page and choose the permalink structure that you prefer:
    Permalink Settings page with Pretty Permalinks
  2. 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:
    Permalink Settings Page with rewrite rule example
  3. 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!
  4. 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.

65 thoughts on “IIS 7 URL Rewrite Module support in WordPress 2.8”

  1. 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!

  2. 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″ />

  3. 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.

  4. 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”?

  5. 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!

  6. 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.

  7. 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.

  8. 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 324

  9. Celso, 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.

  10. 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.

  11. 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

  12. 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.

  13. 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


  14. @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.

  15. 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 ??? 🙁 🙁 🙁

  16. 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 “:”.

  17. 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.

  18. 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:


    <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 name="wordpress" patternSyntax="Wildcard">
    <match url="*" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <action type="Rewrite" url="index.php" />

    Please Note: the wordpress rewrite works fine.

  19. @a43: This is most probably because the pattern for the redirect rule is incorrect. Try this rule instead:

    <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}/" />

  20. 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" />
    <add input="{HTTP_URL}" negate="false" pattern="(/20[0-9][0-9]/\d{2}/\d{2}/)(.*)\.aspx" />
    <action type="Redirect" url="{C:1}{C:2}/" redirectType="Permanent" />

    can you see any differences? I still can’t understand why your suggested rule didn’t work.

  21. 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.

  22. 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.

  23. @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']))

  24. 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.

  25. 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?

  26. 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:

  27. 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?

  28. 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.

  29. 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 .

  30. 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.

  31. Hi,

    I install my blog at


    which is redirected at http://www.mydomain.com/blog/

    the syastem configuration is as below.

    Control panel : plesk 9.7.2
    IIS : 7
    Php : 5.2.13 (Fast CGI Application)
    ASP.NET support : Version 2.0.50727.0

    wordpress : 3.1

    my permalink is default. i try so many things but it’s not change perfectly.

    i write .htaccess

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f # Existing File
    RewriteCond %{REQUEST_FILENAME} !-d # Existing Directory
    RewriteRule . /index.php [L]

    # END WordPress

    what should i have to do..

    plz help me out from this problem.

    i want to use permalink like

    can u plz provide me full code for mod rewrite at my mail id.

    or any other solutions for this problem.

  32. Hey there,

    My server has PHP 5.2.13 installed, and it is running via the FastCGI module. Also, the URL Rewrite module is enabled as well, and its version number looks to be 7.1.0761.0.

    Media uploaded media uploads fine – no errors, photos make thumbnails & 2 other sizes fine – can see all of these files when I ftp in, can pull media down via ftp and view it… but the url path to the original media file (unresized) returns 500 error when used in a page – or even just in a browser. Here’s an original jpg for instance:


    Resized versions show up fine: http://www.beyondthepasta.com/wp-content/uploads/Rome-from-the-Pincian-Hill-300×242.jpg

    but not the original file – which is definitely there.

    Here is my web.config:

    <?xml version="1.0" encoding="UTF-8"?>
    <!– <httpErrors existingResponse="Replace" errorMode="Detailed" />–>
    <remove value="index.php" />
    <add value="index.php" />

    <rewrite><rules><clear />
    <rule name="wordpress" patternSyntax="Wildcard">
    <match url="*" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <action type="Rewrite" url="index.php" />



    Thank you for any assistance 🙂 I will be bald soon if I don’t figure this out!

  33. Hi, how are you Ruslany! i have installed the last version of wordpress but i dont see the web.config. So i have to create it my self or i have to contact my hosting services to create it? Im using IIS 7.5


  34. Hi Brian, you can create the web.config yourself and then add there the rewrite rule. You can copy the rewrite rule from the Settings -> Permalinks page in WordPress.

  35. Hi Muqeet,

    Create an emply text file called web.config and paste there the xml that wordpress gives you. Then save/upload this file to your wordpress site’s root directory.

  36. Hi Ruslany, sorry to bring this post up :0) I’m used to 1-click install of wp and now, I have to move my site (WP 3.1.2) to my own server (IIS). The people who are migrating my website, are telling me that the cannot migrate it, because, on IIS, .htacces URL rewriting is not supported. I have read your post and was wondering if I install wordpress, mysql, that I install/activate URL rewriting module and FASTCGI, is there anything that can go wrong?

    Thank you in advance!

  37. Hi Climatiseur, if you have IIS 7.+ then it support URL rewriting and you can follow the instructions in this post to configure wordpress to use it. I would suggest to install PHP on your server by using web platform installer. That way there is very little change that something is misconfigured or goes wrong.

  38. Hi ruslany!
    Can I use this rewrite rules without installing URL Rewrite Module? – for example, add some modules to my project (such as if RIA service wasn’t installed, i can add few modules to bin directory and it works)
    …or there are one way – ask my hoster to install this?

  39. Hi Artem, unfortunately it is not possible to just drop dll’s to the bin folder. This is a native module (for performance reasons) and requires registration with IIS. So the only way is to ask hoster to install it. At this point it has been around for a while and has proven to work very well. It also has Windows supplemental license, meaning that it is part of the Windows OS and gets the same support as any other Windows OS component. So I do not see any reason why hoster would still not want to enable it on their environment.

  40. Hi Ruslany,

    Looking at the date of your last response it looks like you may still be around to answer my question? If so that would be really good.

    Adam asked this question last year


    My web hoster has the URL Rewrite module installed, and the pretty permalinks are working fine. However, navigating to the home page results in a 404. So, http://blogs.adambarney.com/tech/ is getting the 404. Disabling pretty permalinks will cause this error to go away.

    Any ideas?”

    I am having the same problem, seems like I have everything working apart from when you go to the root of my wordpress blog it returns 404 error. See here: http://www.cccit.co.uk/news
    But if you go to one of my test posts http://www.cccit.co.uk/news/test-post
    It is working fine. Any ideas? It would be very much appriecated!

    Thank you,


  41. Hello again,

    Sorry to keep posting you can probably partly ignore the above posts. I may have misunderstood what you ment.

    Where can I set the default document type for this site, without it affecting the other sites I have hosted. Do I add a line of code to the web.config file or do I log into the server and go to IIS Manager –> Default Document

    At this stage I’m really not sure what I’m doing, but I don’t want to cause issues to my other sites. Thanks again.

  42. Hey,

    first of all, I searched for all kind of permalinks solutions and this seems to be the only one working, many many many thanks ruslany!!
    However: I’ve the same problem as stated above (Oliver): everything works perfect, except the homepage 🙁 it works when i put index.php behind it. I don’t really understand the solution, explaining it in simple words would be so awesome. Many thanks in advance!!

  43. Hi ruslany,
    I used following things

    IIS : 7
    Php : 5.2 (Fast CGI Application)
    wordpress : 3.1
    URL Rewrite Module v2.0 RC

    my permalink is default. And i want use the structure base permalink. I install all the require module which you define above. But when i update the permalink like(/%year%/%monthnum%/%postname%/) but it will not suggest the web.config code as you shown. And i tried to put manually in the web.config file but it gives 404 error.
    plz help me what i have to do for this

    or any other solutions for this problem.

  44. Hi sir,

    I am getting a 404 error whenever i changed the permalink of my site. Do you know why that might be? I meet all the requirements

    php 5.2.13(Fast CGI Application)
    iis 7
    url rewrite 2.0
    wordpress : 3.1

    When i update my permalink it will not suggest any code to me. Even manually i created the web.config file and put the code then it gives the 505 error.
    Is there any solution for this? Thank you.

  45. Thank you for this amazing tutorial. I have also gone through a deep research and found several amazing tutorials for Creating own custom url using the code.

    function prefix_news_rewrite_rule() {
    add_rewrite_rule( ‘news/([^/]+)/photos’, ‘index.php?news=$matches[1]&photos=yes’, ‘top’ );
    add_rewrite_rule( ‘movie/([^/]+)/videos’, ‘index.php?news=$matches[1]&videos=yes’, ‘top’ );

    add_action( ‘init’, ‘prefix_news_rewrite_rule’ );

    Reference: https://www.wpblog.com/wordpress-url-rewrite-for-custom-page-template/

Leave a Reply

Your email address will not be published. Required fields are marked *