Last active
February 10, 2020 18:00
-
-
Save jeremymoore/82bebfbf164a07f63ea3ef4cdf5a1cd7 to your computer and use it in GitHub Desktop.
Web.Config for running Wordpress as a subdirectory on IIS. Additionally, created support for accessing the REST API, which changes routes to match the Site URL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="static" patternSyntax="Wildcard"> | |
<match url="*"/> | |
<conditions> | |
<add input="{REQUEST_URI}" matchType="Pattern" pattern="/wordpress/*" negate="true" /> | |
<add input="{REQUEST_URI}" matchType="Pattern" pattern="/wp-json/*" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> | |
</conditions> | |
<action type="Rewrite" url="index.html" redirectType="Found"/> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
<location path="wordpress"> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<remove name="wordpress" /> | |
<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="wordpress/index.php" redirectType="Found"/> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</location> | |
<location path="wp-json"> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<remove name="api" /> | |
<rule name="api" 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="wordpress/index.php" redirectType="Found"/> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</location> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment