<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <!-- <modules runAllManagedModulesForAllRequests="true"/> -->
    <staticContent>
        <!--<remove fileExtension=".woff" />
        <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
        -->

        <remove fileExtension=".woff" />
        <mimeMap fileExtension=".woff" mimeType="application/x-woff" />

        <remove fileExtension=".woff2" />
        <mimeMap fileExtension=".woff2" mimeType="application/x-woff2" />

        <remove fileExtension=".eot" />
        <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />

        <remove fileExtension=".ttf" />
        <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />

        <remove fileExtension=".svg" />
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.24:00:00" />
    </staticContent>
    <rewrite>
      <rules>

        <rule name="lower case rule" stopProcessing="true">
          <match url="[A-Z]" ignoreCase="false" />
          <action type="Redirect" url="{ToLower:{PATH_INFO}}" appendQueryString="true" />
        </rule>

        <!-- filament -->
        <rule name="Main Rule" stopProcessing="true">
            <match url="^sites/filamentbible/(.*)" />
            <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="filamentbible/index.php" />
        </rule>

        <!-- nlt -->
        <rule name="NLT Redirect" stopProcessing="true">
            <match url="^nlt$" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale.com*" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="nlt/" />
        </rule>

        <rule name="NLT Rule" stopProcessing="true">
            <match url="^nlt/(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale.com*" />
            </conditions>
            <action type="Rewrite" url="be_ix_nlt.aspx?pname={R:1}" />
        </rule>

        <!-- message bible test
        <rule name="Message Test Redirect" stopProcessing="true">
            <match url="^messagebible$" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale.com*" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="messagebible/" />
        </rule>
        <rule name="Message Test Rule" stopProcessing="true">
            <match url="^messagebible/(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale.com*" />
            </conditions>
            <action type="Rewrite" url="be_ix_message.aspx?pname={R:1}" />
        </rule>
        -->

        <!-- brightedge reverse proxy
        <rule name="BrightedgeRedirect">
            <match url="^content$" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale.com*" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="stories/" />
        </rule>
        -->

        <rule name="BrightedgeReWriteTOC">
            <match url="^stories" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale\.(com|local)*" />
            </conditions>
            <action type="Rewrite" url="be_ix.aspx" />
        </rule>

        <rule name="BrightedgeReWrite">
            <match url="^stories/(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="tyndale\.(com|local)*" />
            </conditions>
            <action type="Rewrite" url="be_ix.aspx?pname={R:1}" />
        </rule>

        <rule name="BrightedgeReWriteTOC_NavPress">
            <match url="^stories" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="navpress\.(com|local)*" />
            </conditions>
            <action type="Rewrite" url="be_ix_navpress.aspx" />
        </rule>

        <rule name="BrightedgeReWrite_NavPress">
            <match url="^stories/(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="navpress\.(com|local)*" />
            </conditions>
            <action type="Rewrite" url="be_ix_navpress.aspx?pname={R:1}" />
        </rule>

        <rule name="Remove trailing slash" stopProcessing="true">
          <match url="(.*)/$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="{R:1}" />
        </rule>

        <rule name="Fix first &amp;" stopProcessing="true">
          <match url="(.*)&amp;(.*)" />
          <!-- for some reason the following condition isn't
          required to stop ALL &amp;s from getting changed. -->
          <!-- <conditions>
            <add input="{QUERY_STRING}" pattern="" />
          </conditions> -->
          <action type="Redirect" url="{R:1}?{R:2}" />
        </rule>

        <!-- <rule name="Remove illegal characters (NOT SURE IF WORKING)">
          <match url="^(.*)[&lt;&gt;%:]+(.*)$" />
          <conditions logicalGrouping="MatchAny" />
          <action type="Redirect" url="{R:1}_{R:2}" />
        </rule> -->

        <rule name="Disable Azure Domain" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="*.azurewebsites.net" />
          </conditions>
          <action type="Redirect" url="https://www.tyndale.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Tyndale Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="tyndale.com*" />
          </conditions>
          <action type="Redirect" url="https://www.tyndale.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="NavPress Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          <add input="{HTTP_HOST}" pattern="navpress.com*" />
          </conditions>
          <action type="Redirect" url="https://www.navpress.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="HPG Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          <add input="{HTTP_HOST}" pattern="hendricksonrose.com*" />
          </conditions>
          <!-- <action type="Redirect" url="https://www.hendricksonrose.com{REQUEST_URI}" redirectType="Permanent" /> -->
          <action type="Redirect" url="https://www.hendricksonpublishers.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Hendrickson Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          <add input="{HTTP_HOST}" pattern="hendricksonpublishers.com*" />
          </conditions>
         <action type="Redirect" url="https://www.hendricksonpublishers.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Hendrickson Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
           <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
           <add input="{HTTP_HOST}" pattern="hendricksonpublishers.com*" />
           </conditions>
           <action type="Redirect" url="https://www.hendricksonpublishers.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Rose Goto WWW" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          <add input="{HTTP_HOST}" pattern="rose-publishing.com*" />
          </conditions>
          <action type="Redirect" url="https://www.rose-publishing.com{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Force HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
            <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
            <add input="{HTTP_HOST}" pattern="((qa|dev|prod|npqa|npdev|npprod|www|hpgdev|hpgqa)\.(tyndale|navpress|hendricksonrose|rose-publishing|hendricksonpublishers))\.com.*" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>

        <!-- Dynamic favicons -->
        <rule name="Dynamic Favicons - NavPress" stopProcessing="true">
          <conditions>
            <!-- Matches navpress hostnames -->
            <add input="{HTTP_HOST}" pattern="(np.*|.*\.navpress\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^[A-Za-z0-9x-]*\.(ico|png)$" ignoreCase="true" />
          <action type="Rewrite" url="/ico/navpress/{R:0}" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic Favicons - HPG" stopProcessing="true">
                  <conditions>
                    <!-- Matches HPG hostnames -->
                    <!-- <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendricksonrose\.com).*" ignoreCase="true" /> -->
                    <add input="{HTTP_HOST}" pattern="(hpg.*|.*\.hendrickson-publishers\.com).*" ignoreCase="true" />
                  </conditions>
                  <!-- Matches .ICOs or .PNGs within the root -->
                  <match url="^[A-Za-z0-9x-]*\.(ico|png)$" ignoreCase="true" />
                  <action type="Rewrite" url="/ico/hpg/{R:0}" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic Favicons - HPG" stopProcessing="true">
          <conditions>
            <!-- Matches HPG hostnames -->
            <add input="{HTTP_HOST}" pattern="(hpg.*|.*\.hendricksonpublishers\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^[A-Za-z0-9x-]*\.(ico|png)$" ignoreCase="true" />
          <action type="Rewrite" url="/ico/hpg/{R:0}" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic Favicons - rose" stopProcessing="true">
          <conditions>
            <!-- Matches HPG hostnames -->
            <add input="{HTTP_HOST}" pattern="(hpg.*|.*\.rose-publishers\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^[A-Za-z0-9x-]*\.(ico|png)$" ignoreCase="true" />
          <action type="Rewrite" url="/ico/hpg/{R:0}" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic Favicons - Tyndale" stopProcessing="true">
          <match url="^[A-Za-z0-9x-]*\.(ico|png)$" ignoreCase="true" />
          <!-- Matches .ICOs or .PNGs within the root -->
          <action type="Rewrite" url="/ico/tyndale/{R:0}" redirectType="Permanent" />
        </rule>

        <!-- Dynamic robots.txt -->
        <rule name="Dynamic robots.txt - NavPress" stopProcessing="true">
          <conditions>
            <!-- Matches navpress hostnames -->
            <add input="{HTTP_HOST}" pattern="(np.*|.*\.navpress\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^robots\.txt$" ignoreCase="true" />
          <action type="Rewrite" url="/robots-navpress.txt" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic robots.txt - HPG" stopProcessing="true">
                  <conditions>
                    <!-- Matches hpg hostnames -->
                    <!-- <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendricksonrose\.com).*" ignoreCase="true" /> -->
                    <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendrickson-publishers\.com).*" ignoreCase="true" />
                  </conditions>
                  <!-- Matches .ICOs or .PNGs within the root -->
                  <match url="^robots\.txt$" ignoreCase="true" />
                  <action type="Rewrite" url="/robots-hpg.txt" redirectType="Permanent" />
                </rule>
                  <rule name="Dynamic robots.txt - Hendrickson" stopProcessing="true">
                                          <conditions>
                                            <!-- Matches hpg hostnames -->
                                            <add input="{HTTP_HOST}" pattern="(np.*|.*\.henndricksonpublishers\.com).*" ignoreCase="true" />
                                          </conditions>
                                          <!-- Matches .ICOs or .PNGs within the root -->
                                          <match url="^robots\.txt$" ignoreCase="true" />
                                          <action type="Rewrite" url="/robots-hpg.txt" redirectType="Permanent" />
                                        </rule>
                <rule name="Dynamic robots.txt - Rose" stopProcessing="true">
                          <conditions>
                            <!-- Matches hpg hostnames -->
                            <add input="{HTTP_HOST}" pattern="(np.*|.*\.rose-publishers\.com).*" ignoreCase="true" />
                          </conditions>
                          <!-- Matches .ICOs or .PNGs within the root -->
                          <match url="^robots\.txt$" ignoreCase="true" />
                          <action type="Rewrite" url="/robots-rose.txt" redirectType="Permanent" />
                        </rule>
        <rule name="Dynamic robots.txt - Tyndale" stopProcessing="true">
          <match url="^robots\.txt$" ignoreCase="true" />
          <!-- Matches .ICOs or .PNGs within the root -->
          <action type="Rewrite" url="/robots-tyndale.txt" redirectType="Permanent" />
        </rule>

        <!-- Dynamic sitemap.xml -->
        <rule name="Dynamic sitemap.xml - NavPress" stopProcessing="true">
          <conditions>
            <!-- Matches navpress hostnames -->
            <add input="{HTTP_HOST}" pattern="(np.*|.*\.navpress\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^sitemap\.xml$" ignoreCase="true" />
          <action type="Rewrite" url="/sitemap-navpress.xml" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic sitemap.xml - HPG" stopProcessing="true">
          <conditions>
            <!-- Matches hpg hostnames -->
            <!-- <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendricksonrose\.com).*" ignoreCase="true" /> -->
            <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendrickson-publishers\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^sitemap\.xml$" ignoreCase="true" />
          <action type="Rewrite" url="/sitemap-hpg.xml" redirectType="Permanent" />
        </rule>
         <rule name="Dynamic sitemap.xml - Hendrickson" stopProcessing="true">
                  <conditions>
                    <!-- Matches hendrickson hostnames -->
                    <add input="{HTTP_HOST}" pattern="(np.*|.*\.hendricksonpublishers\.com).*" ignoreCase="true" />
                  </conditions>
                  <!-- Matches .ICOs or .PNGs within the root -->
                  <match url="^sitemap\.xml$" ignoreCase="true" />
                  <action type="Rewrite" url="/sitemap-hendrickson.xml" redirectType="Permanent" />
                </rule>
        <rule name="Dynamic sitemap.xml - HPG" stopProcessing="true">
          <conditions>
            <!-- Matches rose hostnames -->
            <add input="{HTTP_HOST}" pattern="(np.*|.*\.rose-publishing\.com).*" ignoreCase="true" />
          </conditions>
          <!-- Matches .ICOs or .PNGs within the root -->
          <match url="^sitemap\.xml$" ignoreCase="true" />
          <action type="Rewrite" url="/sitemap-rose.xml" redirectType="Permanent" />
        </rule>
        <rule name="Dynamic sitemap.xml - Tyndale" stopProcessing="true">
          <match url="^sitemap\.xml$" ignoreCase="true" />
          <!-- Matches .ICOs or .PNGs within the root -->
          <action type="Rewrite" url="/sitemap-tyndale.xml" redirectType="Permanent" />
        </rule>

        <rule name="404 Rule" stopProcessing="true">
          <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>

        <!--
        <rule name="Redirect Negated Sites - Tyndale" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}{REQUEST_URI}" pattern="^www.tyndale.com/sites/test1(.+)" />
            </conditions>
            <action type="Redirect" url="https://www.tyndale.com" redirectType="Permanent" />
        </rule>

        <rule name="Redirect Negated Sites - NavPress" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}{REQUEST_URI}" pattern="^www.navpress.com/sites/test2(.+)" />
            </conditions>
            <action type="Redirect" url="https://www.navpress.com" redirectType="Permanent" />
        </rule>
        -->
      </rules>
    </rewrite>
    <!-- limit
    <caching enabled="true" >
          <profiles>
            <add extension=".html" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".zip" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
            <add extension=".rar" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
          </profiles>
        </caching>
     -->
    <urlCompression doDynamicCompression="true" doStaticCompression="true" />
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Methods" value="HEAD,GET,OPTIONS" />
        <add name="X-Content-Type-Options" value="nosniff" />
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="X-XSS-Protection" value="1; mode=block" />
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>
    <rewrite>
        <outboundRules>
          <rule name="Remove RESPONSE_Server">
            <match serverVariable="RESPONSE_Server" pattern=".+" />
            <action type="Rewrite" value="" />
          </rule>
        </outboundRules>
      </rewrite>
        <handlers>
            <clear />
            <add name="PHP_via_FastCGI6" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v7.4\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI4" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v7.1\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI1" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files\iis express\PHP\v7.1\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI5" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files\iis express\PHP\v7.4\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI2" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files\iis express\PHP\v7.2\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI3" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v7.0\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v7.2\php-cgi.exe" resourceType="Either" />
            <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" />
            <add name="CGI-exe" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />
            <add name="TRACEVerbHandler" path="*" verb="TRACE" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule" resourceType="Either" requireAccess="Read" />
        </handlers>
  </system.webServer>
  <system.web>
    <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
    <pages validateRequest="false" />
    <customErrors mode="Off" />
  </system.web>
</configuration>
