<?xml version="1.0" encoding="UTF-8" ?>
<!-- app configuration for web2py on IIS -->
<configuration>
  <appSettings>
    <add key="WSGI_HANDLER" value="gluon.main.wsgibase" />
    <add key="WSGI_RESTART_FILE_REGEX" value=".*((routes\.py)|(\.config))$" />
  </appSettings>
  <system.webServer>
    <rewrite>
      <rules>
        <clear />
        <rule name="static" enabled="true" stopProcessing="true">
          <match url="^(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="applications/{R:1}/static/{R:2}" logRewrittenUrl="false" />
        </rule>
        <rule name="web2py_app" enabled="true" stopProcessing="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="handler.web2py/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
      <outboundRules>
        <rule name="static_version_cache_control" preCondition="static_version">
          <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
          <action type="Rewrite" value="max-age=315360000" />
          <conditions>
          </conditions>
        </rule>
        <rule name="static_version_Expires" preCondition="static_version">
          <match serverVariable="RESPONSE_Expires" pattern=".*" />
          <action type="Rewrite" value="Thu, 31 Dec 2037 23:59:59 GMT" />
        </rule>
        <preConditions>
          <preCondition name="static_version">
            <add input="{REQUEST_URI}" pattern="(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$" />
          </preCondition>
        </preConditions>
      </outboundRules>
    </rewrite>
    <handlers>
      <!-- replace SCRIPT_PROCESSOR with the configured handler for python -->
      <add name="Python_via_FastCGI" path="handler.web2py" verb="*" modules="FastCgiModule" scriptProcessor="SCRIPT_PROCESSOR" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
  </system.webServer>
</configuration>