Search code examples
wordpressweb-confighttp-status-code-404windows-server

Wordpress subpages give 404 in windows subdirectory installation


I am migrating a site from a linux server to a windows server. The site has a wordpress installation in a /blog subfolder. All the pages of the wordpress site give a 404, except for the homepage.

I tried adding the following to the web.config, which is in the root of the domain:

    <rewrite>
      <rules>
        <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>

As this had worked for previous windows wordpress installations, but those previous installations were in the root of the domain, not in a subdirectory.

Please help.


Solution

  • So in the end, I just needed to put the web.config file, with the above snippet in the subfolder where my wp installation was AND remove it from the root of the domain. I had previously done the former without the latter only.