Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active January 2, 2021 05:39
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 BananaAcid/65947dd61965dfc1bd233786fa6aeca7 to your computer and use it in GitHub Desktop.
Save BananaAcid/65947dd61965dfc1bd233786fa6aeca7 to your computer and use it in GitHub Desktop.
contao/iis web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- HTTPS !!
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
HTTPS -->
<!-- # Prevent access to the Contao template files
<FilesMatch "\.(tpl|html5|xhtml)$">
Deny from all
-->
<rule name="contao/-templates" stopProcessing="true">
<match url="^(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern=".*\.(tpl|html5|xhtml|phtml)" negate="false" />
</conditions>
<action type="Rewrite" url="/cms/index.php/403/{R:1}" />
</rule>
<!--
/.htaccess
RewriteCond %{REQUEST_URI} !^cms/.*
RewriteRule ^(.*) /cms/$1 [L]
##stopProcessing="true"
-->
<rule name="contao/" >
<match url="^(.*)" ignoreCase="false" />
<conditions>
<add input="{URL}" pattern="^cms/.*" ignoreCase="false" negate="true" />
<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" />
</conditions>
<action type="Rewrite" url="/cms/index.php/{R:1}" />
</rule>
<rule name="contao/contao" >
<match url="^contao/" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/(files|assets|system|share).*" negate="true" />
<add input="{URL}" pattern="^cms/.*" ignoreCase="false" negate="true" />
<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="/cms/contao/" />
</rule>
<rule name="contao/contao/*" >
<match url="^contao/(.+)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/(files|assets|system|share).*" negate="true" />
<add input="{URL}" pattern="^cms/.*" ignoreCase="false" negate="true" />
<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="/cms/contao/index.php/{R:1}" />
</rule>
<!--
cms/.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ index.php [L]
RewriteRule (.*\.html)$ index.php/$1 [L]
supports $GLOBALS['TL_CONFIG']['addLanguageToUrl'] = true; and false;
-->
<rule name="contao/cms" >
<match url="^(cms/)*(.*\.html)" ignoreCase="false" />
<conditions>
<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="/cms/index.php/{R:2}" />
</rule>
<!-- .... -->
<rule name="contao/files|assets|system|share" stopProcessing="true">
<match url="^(files|assets|system|share)/(.*)" ignoreCase="false" />
<conditions>
<!-- .txt + .php for system/cron/cron.php by frontend -->
<add input="{REQUEST_URI}" pattern=".*\.(ico|gif|jpg|jpeg|png|js|css|txt|ttf|woff|xml|php)" negate="false" />
<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="/cms/{R:1}/{R:2}" />
</rule>
<rule name="contao/de|en|../" stopProcessing="true">
<match url="^([^\/]+)/(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_URI}" pattern=".*\.(ico|gif|jpg|jpeg|png|js|css|txt|ttf|woff|xml)" negate="true" />
</conditions>
<action type="Rewrite" url="/cms/index.php/{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment