Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to Setup WordPress Permalinks on Windows IIS ======================================= Place this file into the base directory of your WordPress installation to allow permalinks (or "pretty URLs") on Windows IIS.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<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>
@developer-prosenjit

This comment has been minimized.

Show comment Hide comment
@developer-prosenjit

developer-prosenjit Sep 24, 2013

Ok.. I try this code. It's working.. But When upload image through media library. Any image not loading, if I access through image url. Just showing the 404 error. Have any Idea?

Ok.. I try this code. It's working.. But When upload image through media library. Any image not loading, if I access through image url. Just showing the 404 error. Have any Idea?

@Ben-Malkin

This comment has been minimized.

Show comment Hide comment
@Ben-Malkin

Ben-Malkin Feb 6, 2015

Excellent, thank you very much for this. Saved hours of trawling through Wordpress forums.

Excellent, thank you very much for this. Saved hours of trawling through Wordpress forums.

@the-coding-panda

This comment has been minimized.

Show comment Hide comment
@the-coding-panda

the-coding-panda Aug 19, 2015

Again, thanks guys - saved me a lot of time!

Again, thanks guys - saved me a lot of time!

@JoshDobbin

This comment has been minimized.

Show comment Hide comment
@JoshDobbin

JoshDobbin Oct 22, 2015

To make the image URL work, you'll need to tell the rule to stop processing if it hits the wp-content path
Within the conditions node, add this rule before all the others:

        <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/wp-content/" negate="true" />

This should result in that url path returning images and other content.

To make the image URL work, you'll need to tell the rule to stop processing if it hits the wp-content path
Within the conditions node, add this rule before all the others:

        <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/wp-content/" negate="true" />

This should result in that url path returning images and other content.

@heloisabiagi

This comment has been minimized.

Show comment Hide comment
@heloisabiagi

heloisabiagi May 26, 2016

Thanks, you saved my day! One question: what if the Wordpress website is located in a subfolder, i.e /blog, but I want it to be accessible from the main domain example.com? I know in Apache all I have to do is to keep an .htaccess copy in both the root and /blog directory, but how about in IIS?

Thanks, you saved my day! One question: what if the Wordpress website is located in a subfolder, i.e /blog, but I want it to be accessible from the main domain example.com? I know in Apache all I have to do is to keep an .htaccess copy in both the root and /blog directory, but how about in IIS?

@BhavyaPK

This comment has been minimized.

Show comment Hide comment
@BhavyaPK

BhavyaPK Mar 23, 2017

Hi, I'm trying to upload an image into website .image is updated in database but not showing ,only gray color box is displaying in the media library.
I've tried to uninstall all plugins and the theme which i was using but didn't work

BhavyaPK commented Mar 23, 2017

Hi, I'm trying to upload an image into website .image is updated in database but not showing ,only gray color box is displaying in the media library.
I've tried to uninstall all plugins and the theme which i was using but didn't work

@jeremymoore

This comment has been minimized.

Show comment Hide comment
@jeremymoore

jeremymoore Jun 27, 2017

This was so helpful... I ended up creating a slightly different version for my situation where Wordpress was in a subdirectory and where I needed the REST api to be reachable. https://gist.github.com/jeremymoore/82bebfbf164a07f63ea3ef4cdf5a1cd7

This was so helpful... I ended up creating a slightly different version for my situation where Wordpress was in a subdirectory and where I needed the REST api to be reachable. https://gist.github.com/jeremymoore/82bebfbf164a07f63ea3ef4cdf5a1cd7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment