Skip to content

Instantly share code, notes, and snippets.

@stirtingale
Forked from addisonhall/web.config
Created November 8, 2018 15:43
Show Gist options
  • Save stirtingale/86741c83863f1ffdc8a4feee82453f1e to your computer and use it in GitHub Desktop.
Save stirtingale/86741c83863f1ffdc8a4feee82453f1e to your computer and use it in GitHub Desktop.
WordPress on IIS web.config with headers and cache control. Be sure to update "http://mydomain.com" with your site domain.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding"></add>
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
<rewrite>
<rules>
<rule name="WordPress: http://mydomain.com" 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>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding"></add>
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
<rewrite>
<rules>
<!-- Begin WP Super Cache: http://www.am22tech.com/speed-up-wordpress-on-iis-windows-wp-super-cache/ -->
<rule name="WP super cache Windows WordPress" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern=".*=.*" negate="true" />
<add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true" />
<add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress|wp-postpass_).*$" negate="true" />
<add input="{DOCUMENT_ROOT}/wp-content/cache/supercache/{HTTP_HOST}/{R:1}index.html" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="wp-content/cache/supercache/{HTTP_HOST}/{R:1}index.html" />
</rule>
<!-- End WP Super Cache -->
<rule name="WordPress: http://mydomain.com" 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment