<?xml version="1.0" encoding="utf-8"?>
<!-- IIS settings for the static site (UAT/production run IIS 10).
     IIS only serves file types listed in its MIME map and answers 404 for the
     rest, so .webp images, the web manifest and the /admin config need
     entries. <remove> first keeps this valid on servers that already map them. -->
<configuration>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".webp" />
      <mimeMap fileExtension=".webp" mimeType="image/webp" />
      <remove fileExtension=".avif" />
      <mimeMap fileExtension=".avif" mimeType="image/avif" />
      <remove fileExtension=".webmanifest" />
      <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
      <remove fileExtension=".yml" />
      <mimeMap fileExtension=".yml" mimeType="text/yaml" />
      <!-- Browser caching. Pages (HTML), robots.txt and sitemaps: always
           re-checked with the server (a cheap 304 when unchanged), so edits
           show at once. css/, js/ and fonts/ are kept a year and images 30
           days; see the <location> blocks at the end of this file. CSS/JS
           links carry ?v=<content hash> (tools/stamp-assets.mjs), so a
           changed file gets a new URL. -->
      <clientCache cacheControlMode="DisableCache" />
    </staticContent>
    <!-- HSTS: browsers use HTTPS only for this host for a year. -->
    <httpProtocol>
      <customHeaders>
        <remove name="Strict-Transport-Security" />
        <add name="Strict-Transport-Security" value="max-age=31536000" />
      </customHeaders>
    </httpProtocol>
    <!-- Clean URLs: every page has one address, without ".html".
         /about serves about.html; /about.html and /about/ 301 to /about;
         /index.html 301s to /. Needs the IIS URL Rewrite 2.1 module
         (https://www.iis.net/downloads/microsoft/url-rewrite); without it IIS
         rejects this file with error 500.19 on every request.
         The redirects test {UNENCODED_URL} (the address the browser asked for)
         so the internal rewrite and IIS's default document never loop. -->
    <rewrite>
      <!-- Truncated blog links Google found from the old site (Search Console,
           Oct 2026) and the post each one belongs to. "embracing-" matches
           three posts, so it goes to the blog index. The last four are old
           posts whose slugs were lengthened in Squidex (Nov 2026). -->
      <rewriteMaps>
        <rewriteMap name="BlogMoves">
          <add key="/blog/new-year-" value="/blog/new-year-resolutions-for-mutual-fund-distributors" />
          <add key="/blog/the-15-" value="/blog/the-15-year-journey" />
          <add key="/blog/how-robust" value="/blog/how-robust-portfolio-construction-and-asset-allocation-drive-long-term-success-for-mutual-fund-distributors" />
          <add key="/blog/a-journey-" value="/blog/a-journey-through-time" />
          <add key="/blog/redefining-" value="/blog/redefining-prosperity-for-your-clients" />
          <add key="/blog/embracing-" value="/blog" />
          <add key="/blog/dussehras-" value="/blog/dussehras-timeless-lessons-for-financial-advisors" />
          <add key="/blog/celebrating-indias-independence-day" value="/blog/celebrating-indias-independence-day-financial-independence-for-mutual-fund-distributors" />
          <add key="/blog/gandhi-jayanti" value="/blog/gandhi-jayanti-timeless-lessons-for-mutual-fund-distributors" />
          <add key="/blog/i-have-a-dream" value="/blog/i-have-a-dream-a-path-to-10x-growth-for-independent-financial-advisors" />
          <add key="/blog/the-top-10-money-mistakes-people-make" value="/blog/the-top-10-money-mistakes-people-make-and-how-to-avoid-them" />
        </rewriteMap>
      </rewriteMaps>
      <rules>
        <!-- Repeated slashes in the path (www.wylth.com//platform-terms):
             IIS serves the page anyway, and its relative links then keep
             the "//". 301 to the address with one slash; each redirect
             removes one run, so a path with several runs settles in a few
             hops. Only the path is tested, so a "//" in a query string
             (?next=https://...) is left alone. -->
        <rule name="Collapse repeated slashes" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{UNENCODED_URL}" pattern="^([^?]*?)//+([^?]*(?:\?.*)?)$" />
          </conditions>
          <action type="Redirect" url="{C:1}/{C:2}" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <!-- One URL per page: lowercase, no .html, no trailing slash, in a
             single 301 (/Blog/Deepavali, /Platform/, /About.html). Only
             addresses without a file extension (pages, not images or CSS). -->
        <rule name="Lowercase pages" stopProcessing="true">
          <match url="^([^.]*[A-Z][^.]*?)(?:\.html)?/?$" ignoreCase="false" />
          <action type="Redirect" url="/{ToLower:{R:1}}" redirectType="Permanent" />
        </rule>
        <!-- Old site blog links: /blog/blogslug?c=the-ripple-effect -->
        <rule name="Old blog query links" stopProcessing="true">
          <match url="^blog/blogslug/?$" />
          <conditions>
            <add input="{QUERY_STRING}" pattern="(?:^|&amp;)c=([^&amp;]+)" />
          </conditions>
          <action type="Redirect" url="/blog/{C:1}" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <rule name="Truncated blog links" stopProcessing="true">
          <match url="^(blog/[^/]+?)/?$" />
          <conditions>
            <add input="{BlogMoves:/{R:1}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <!-- /login is the CRM; /studio is studio.wylth.com (one address each). -->
        <rule name="Login is the CRM" stopProcessing="true">
          <match url="^login(\.html)?/?$" />
          <action type="Redirect" url="https://crm.wylth.com/" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <rule name="Studio is its own site" stopProcessing="true">
          <match url="^studio(\.html)?/?$" />
          <action type="Redirect" url="https://studio.wylth.com/" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <!-- The old /solution page now lives on the home page (#solution). A
             real 301 instead of solution.html's meta refresh, so search engines
             move it to the home page. -->
        <rule name="Solution moved to home" stopProcessing="true">
          <match url="^solution(\.html)?/?$" />
          <action type="Redirect" url="/#solution" redirectType="Permanent" appendQueryString="false" />
        </rule>
        <!-- Blog addresses are now without brackets or trailing hyphens
             (blog/...-(2026) -> blog/...-2026, blog/...-advisor- -> blog/...-advisor). -->
        <rule name="Blog slug without brackets" stopProcessing="true">
          <match url="^blog/(.*?)(?:\(|%28)(.*?)(?:\)|%29)(.*?)(?:\.html)?$" />
          <action type="Redirect" url="/blog/{R:1}{R:2}{R:3}" redirectType="Permanent" />
        </rule>
        <rule name="Blog slug without trailing hyphen" stopProcessing="true">
          <match url="^blog/(.+?)-+(?:\.html)?/?$" />
          <action type="Redirect" url="/blog/{R:1}" redirectType="Permanent" />
        </rule>
        <!-- Other spellings of the thank-you page that forms or links may use. -->
        <rule name="Thank-you page aliases" stopProcessing="true">
          <match url="^(thank-you|home/thank-?you)/?$" />
          <action type="Redirect" url="/thankyou" redirectType="Permanent" />
        </rule>
        <rule name="Home without index.html" stopProcessing="true">
          <match url="^(.*/)?index(\.html)?$" />
          <conditions>
            <add input="{UNENCODED_URL}" pattern="^/(.*/)?index(\.html)?(\?|$)" />
          </conditions>
          <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="Drop .html" stopProcessing="true">
          <match url="^(.+)\.html$" />
          <conditions>
            <add input="{UNENCODED_URL}" pattern="\.html(\?|$)" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" />
            <!-- Draft/source pages keep their file names (noindex below). -->
            <add input="{R:1}" pattern="^(variation|wylthhomerevampv26_3|wylth-[a-z]+-v1|\+c\+|'\+g\+)" negate="true" />
          </conditions>
          <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="No trailing slash on pages" stopProcessing="true">
          <match url="^(.+)/$" />
          <conditions>
            <add input="{APPL_PHYSICAL_PATH}{R:1}.html" matchType="IsFile" />
          </conditions>
          <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="Serve page.html at /page" stopProcessing="true">
          <match url="^(.+)$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}.html" matchType="IsFile" />
          </conditions>
          <action type="Rewrite" url="{R:1}.html" />
        </rule>
      </rules>
    </rewrite>
    <security>
      <requestFiltering>
        <!-- Build scripts, CI config and build-time data are not part of the site. -->
        <hiddenSegments>
          <add segment="tools" />
          <add segment=".github" />
          <add segment="azure-pipelines" />
          <add segment="node_modules" />
          <add segment="content" />
          <add segment="package.json" />
          <add segment="package-lock.json" />
          <add segment="site-pages.json" />
          <add segment="netlify.toml" />
          <!-- Draft and source pages from the rebuild; not part of the site. -->
          <add segment="variation.html" />
          <add segment="wylthhomerevampv26_3 (3).html" />
          <add segment="+c+.html" />
          <add segment="'+g+'.html" />
        </hiddenSegments>
      </requestFiltering>
    </security>
  </system.webServer>

  <!-- Long browser caching for assets (see <clientCache> above). -->
  <location path="css">
    <system.webServer><staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /></staticContent></system.webServer>
  </location>
  <location path="js">
    <system.webServer><staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /></staticContent></system.webServer>
  </location>
  <location path="fonts">
    <system.webServer><staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /></staticContent></system.webServer>
  </location>
  <location path="images">
    <system.webServer><staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /></staticContent></system.webServer>
  </location>
  <location path="src">
    <system.webServer><staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /></staticContent></system.webServer>
  </location>

  <!-- Draft/source pages stay out of search results (IIS equivalent of _headers). -->
  <location path="variation.html">
    <system.webServer><httpProtocol><customHeaders><add name="X-Robots-Tag" value="noindex, nofollow" /></customHeaders></httpProtocol></system.webServer>
  </location>
  <location path="wylthhomerevampv26_3 (3).html">
    <system.webServer><httpProtocol><customHeaders><add name="X-Robots-Tag" value="noindex, nofollow" /></customHeaders></httpProtocol></system.webServer>
  </location>
</configuration>
