Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: IIS - URL rewrite  (Read 522 times)

chenks

  • Reg Member
  • ***
  • Posts: 999
IIS - URL rewrite
« on: November 27, 2021, 06:06:12 PM »

any IIS gurus here?

i'm trying to set up a URL rewrite to allow a temporary "under maintenance" page to be displayed.
the rewrite works, however it's also filtering out the CSS and JS files that the page links to.

i know i need to set a rule to exlude them, but can't seem to get it to work.
anyone know the correct way to do this?

the following is what's currently set up

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
  <match url="(.*)" />
<conditions>
  <add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="Site Maintenance" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="maintenance" negate="true" />
<add input="{REQUEST_URI}" pattern="images" negate="true" />
</conditions>
<action type="Redirect" url="/maintenance.asp" appendQueryString="false" redirectType="Temporary" />
</rule>
            </rules>
        </rewrite>
        <staticContent>
            <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
            <clientCache cacheControlMode="DisableCache" />
        </staticContent>
        <caching enabled="false" enableKernelCache="false">
            <profiles>
                <add extension=".js" policy="DisableCache" kernelCachePolicy="DisableCache" />
            </profiles>
        </caching>
        <httpErrors errorMode="Detailed">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

and the CSS and JS files are located in

Code: [Select]
<link rel="stylesheet" href="/includes/css/style.css"/>
<script src="/includes/scripts/startscript.js"></script>

the page that is being used as the redirect is /maintenance.html
Logged

chenks

  • Reg Member
  • ***
  • Posts: 999
Re: IIS - URL rewrite
« Reply #1 on: November 27, 2021, 06:44:48 PM »

i think i worked it out, for anyone that might need to know in the future
i added the following lines to the rule

Code: [Select]
<add input="{URL}" negate="true" pattern="\.css$" />
<add input="{URL}" negate="true" pattern="\.js$" />
Logged
 

anything