WordPress Permalinks on Windows IIS

Thursday, November 12, 2009 @ 10:11 AM
admin

WordPress is written in PHP, and generally php runs better under apache on Linux, but you can run it on IIS on Windows machines. In fact this blog is running under Windows.*

If you find you have changed the permalinks options in your wordpress installation, but you find they don’t work,  first check if you are running on a Windows machine. On a shared hosting account, it should have said whether it was windows or linux, but at the least, if you have the option for asp.net, then you are on windows.

If you are on a Linux machine under apache, there are loads of resources for making sure permalink rewrites work. Running WordPress on windows however is much less common, so I thought I would post a quick fix for getting it to run under IIS7.

The trick involves adding a web.config file to your base installation. A web.config file is a configuration file used by Windows specifically for .net, but in this case if you are running wordpress you can trick IIS into passing the buck on files it can’t find to WordPress, that then handles it.

Simply ensure the URL Rewrite module is enabled on the IIS server (lots of hosts, including GoDaddy, have this enabled, but talk to your hosting company if it doesn’t), then add the following web.config file to the base of your WordPress installation.

web.config.txt

Note – windows prevents downloading anything with .config by default at the end, so download this file, remove the .txt at the end, then upload.

Good luck, and post comments if you still have problems!

* “Why the hell would you do that??” I hear you say! Generally web devs are fans of either languages made to run on proprietory systems (ASP.NET, Coldfusion etc) or open source Linux or Unix systems (php, ruby etc). Two reasons – It’s because I do both php (which runs on both) and ASP.NET dev, which only runs on Windows. To occasionally demonstrate some .net stuff on this blog, I need it to be on windows, or host it separately. Second, its using IIS7, which handles php almost as well as Apache. Linux and Windows fans – feel free to fight it out in the comments!
Like this? Share it!
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • email
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Buzz

24 Responses to “WordPress Permalinks on Windows IIS”

  1. David says:

    thanx for your writing to post, I like your web site and good lucky. Regards.

  2. Sam says:

    Thanks for posting this, I was new to the whole Web.config thing running my first Windows server. This was a big help!!!

  3. loalkenue says:

    I am often looking for brandnew posts in the net about this issue. Thx!

  4. nikks says:

    GRRRR… I’ve uploaded this file into the server under wordpress, but it still doesn’t work… my permalink still has the 404 error… can someone advice?

  5. Ed says:

    Thanks! This worked brilliantly. Every time I enabled permalinks, WordPress was creating a blank web.config file which would cause 500 errors until I deleted it again. No longer!
    Ed

  6. DenniSys says:

    Error occurs RE:
    web.config.txt

    Save Target As:
    The system cannot find the file specified
    file:///C:/web.config.txt

    Could you publish the text of the file on this page please?
    You can use the HTML tags around the text and the server will treat the text similar to a comment, ie, it won’t attempt
    to execute it. Some servers use the [code][/code] tags to do the same thing. Thank you.

  7. DenniSys says:

    The pre – end pre html tags i wrote in the above reply do not display, so they may work or not for the response. Wish I could edit my reply. Hint Hint.

  8. Lex says:

    This worked for me.
    Excellent!
    Thank you for the post!!!

  9. vikash singh says:

    no this is not working for me. still showing 404 error.

  10. Gary says:

    This seems to work if WordPress is installed in the root folder of the website. But I have mine in a sub folder. (All permissions are fine.) But I still get the 404 error.

    I tried changing the line:

    to

    but that doesn’t work.

    I also tried putting the web.config file in the root of the website and also in the wp folder. Tried different changes to the above line, but nothing works.

    Any advice when running WordPress from a sub folder on IIS7 and Windows 2008 server??

    Thanks,
    Gary

  11. If the rewrite module is not enabled by the host and they are unwilling to do so does anyone know of a hack that will get round this?

  12. Jan says:

    THANK YOU.
    Took me most of the day to get pretty URLs running.
    THANK YOU.
    Regards
    Jan

  13. Chris Davenport says:

    Yay! Worked for me – many thanks.

  14. John says:

    This worked like a charm.. Thank you! I added some stuff tho!

    FYI,

    If you open up a new xml file in Dreamweaver and save the below as web.config and them drop it in your root wordpress install this will help with your upload file sizes too..
    ———————————————————————————————-

  15. John says:

    Here’s the updated file i used.. The file will say web.. but it’s web.config.. you just can see it. don’t change it.

    http://www.filedump.net/index.php?pic=web1320983378.zip

  16. compra dominio…

    [...]Wordpress Permalinks on Windows IIS | Global Artwork[...]…

  17. Shaz says:

    Hi,

    I recently transferred a wordpress site from Apache server to IIS. Friendly Urls (custom permalinks are not working). Everytime I update permalinks to custom wordpress tries to write to .htaccess file and displays a code that I should add to .htaccess file since it is not writeable.
    When I click on a link on the site it says: The system cannot find the file specified.
    The permalinks work if I use one of the preset layouts, but that would mean having index.php in the link structure which is not what I want.

    Could someone please assist me on this matter, any insight will be greatly appreciated.

    Many thanks

  18. John Reeve says:

    Holy crow you saved my bacon! Thanks!

    For moving a WP site from an apach DEV server to an IIS live server (not my idea), this totally fixed my issue!

  19. Drifter Morning says:

    Thank you so much! Christ, the documentation on this point is so poor elsewhere.

  20. James says:

    I’m also having problems getting this to work with WordPress installed in a subfolder – does anybody have any suggestions? Many thanks!

  21. Ketan says:

    Works perfectly.. web.config.txt didn’t worked for me.. so I created web.config and upload to my shared host server. it works.. !! Thanks a lot..

Leave a Reply

About Us

Global Artwork is a collection of contract web developers, designers, UX consultants and general webby people.

We have all worked together at various stages of our careers at the top of the industry, on some of the best clients. We don't wan't mainstream. You don't want mainstream. The web doesn't do mediocre - neither should you.

If you have an interesting project, swing by and ask us for advice.

more >>