Skip to content

Instantly share code, notes, and snippets.

@mjau-mjau
Last active May 24, 2020 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjau-mjau/87ad64f35b3860e9efd841131174b52a to your computer and use it in GitHub Desktop.
Save mjau-mjau/87ad64f35b3860e9efd841131174b52a to your computer and use it in GitHub Desktop.
X3 web.config for Microsoft IIS server
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- Prevent web access to all files in the /config/ directory -->
<security>
<requestFiltering>
<hiddenSegments>
<add segment="config" />
</hiddenSegments>
</requestFiltering>
</security>
<!-- X3 rewrite rules -->
<rewrite>
<rules>
<!-- Rewrite any calls to *.html, *.json, *.xml, *.atom or *.rss if a folder matching * exists -->
<rule name="Rewrite any calls to *.html, *.json, *.xml, *.atom or *.rss if a folder matching * exists" stopProcessing="false">
<match url="(.+)\.(html|json|xml|atom|rss)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}/" />
</rule>
<!-- Add a trailing slash to directories -->
<rule name="Add a trailing slash to directories" stopProcessing="false">
<match url="([^/]+)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="(\.|\?)" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="(.*)/$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}/" />
</rule>
<!-- Rewrite any calls to /render to the image parser -->
<rule name="Rewrite any calls to /render to the image parser" stopProcessing="false">
<match url="^render/." ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="render/" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="app/parsers/slir/" />
</rule>
<!-- Rewrite routes to index.php if they are non-existent files/dirs -->
<rule name="Rewrite routes to index.php if they are non-existent files/dirs" stopProcessing="false">
<match url="^(.*)/$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?/{R:1}/" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment