SOLVED: 404 Error on WordPress Posts & Pages When Running on IIS


A default install of IIS on Server 2008, 2012 or 2016 does support URL rewriting the way WordPress expects.  This means that if you change the PERMALINK structure from the default (and ugly and SEO killing) page ID so your URLs look like:  .  If you do change the PERMALINK setting to something that humans understand and search engines like, you will see:

404 – File or directory not found

Fortunately this is easy to fix.  As you can see in the screen shot, when you change the PERMALINKS settings, the page tells you to update your WEB.CONFIG and that is what you need to do.

The solution is to enable URL REWRITE v1.1 which can be done with some simple text:

<?xml version=”1.0″ encoding=”UTF-8″?>
<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”/>

Just add that text to your WEB.CONFIG file being careful not to remove any of the existing content from your WEB.CONFIG.

  • If this is a fresh install, you likely will not have a WEB.CONFIG file so you can just create one using notepad (or any other plain text editor).
  • Note that you may have to remove the <CONFIGURATION> and </CONFIGURATION> tags from this if your existing web.config already has those tags

WEB.CONFIG needs to be in the root of your site.  So for many people that will be C:\inetpub\wwwroot\<YourAwesomeWPressSite> .

You do not even have to do an IIS reset on this for it to start working.

Thanks to @kartiks16 and @hyperionstudios from the WordPress support forum for helping me with this one.


  1. Avatar
    Alex Rodrigues June 21, 2019 at 8:15 am

    With the code in the post, my entire site stayed out :D. But, with this part behind, all is ok!

Questions or Comments?