Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Forked from adilmughal/blog.web.config
Created September 4, 2018 05:12
Show Gist options
  • Save mikestratton/9d53a2088ce2f85fd543b9c77da3feb5 to your computer and use it in GitHub Desktop.
Save mikestratton/9d53a2088ce2f85fd543b9c77da3feb5 to your computer and use it in GitHub Desktop.
Web.config URL rewriting rules for hosting WordPress (PHP) on IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove html" stopProcessing="true">
<match url="(.*).html$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
<rule name="Main Rule" 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>
<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>
</system.webServer>
</configuration>
@mikestratton
Copy link
Author

If you receive this or a similar error in Wordpress:
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
7: 8: 9:

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