Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

URL Rewrite

$
0
0

I am having difficulty enabling CORS for multiple domains using URL rewrite. The difficulty seems to be capturing HTTP_ORIGIN of the request. I have attempted two methods that others have used, and each one fails to rewrite the HTTP_ORIGIN.

First I tried as follows. Note that I commented out "<add input="https://myserver.katyisd.org" />.  That will work if un-commented, but that would defeat the purpose here.

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><httpProtocol><customHeaders><add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" /><add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,PUT,DELETE" /><add name="Access-Control-Allow-Credentials" value="true" /></customHeaders></httpProtocol><rewrite>            <outboundRules><clear />                <rule name="AddCrossDomainHeader"><match serverVariable="RESPONSE_Access_Control_Allow_Origin" pattern=".*" /><conditions logicalGrouping="MatchAll" trackAllCaptures="true"><add input="{HTTP_ORIGIN}" pattern="(http(s)?://((.+\.)?katyisd\.org|(.+\.)?myserver.katyisd\.org|(.+\.)?mygis.katyisd\.org))" /><!--	<add input="{HTTP_ORIGIN}" pattern="(http(s)?://((.+\.)?katyisd\.org|(.+\.)?\.org|(.+\.)?domain3\.com))" />--><!--	<add input="https://myserver.katyisd.org" />--></conditions><action type="Rewrite" value="{C:0}" /></rule>           </outboundRules></rewrite></system.webServer></configuration>

I also tried as follows. However same result, : 

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules><rule name="CaptureRequestOrigin"><match url=".*" /><conditions><add input="{HTTP_ORIGIN}" pattern=".+" /></conditions><serverVariables><set name="CAPTURED_ORIGIN" value="{C:0}" /></serverVariables><action type="None" /></rule></rules><outboundRules><rule name="SetAccessControlAllowOrigin"><match serverVariable="RESPONSE_Access_Control_Allow_Origin" pattern=".+" negate="true" /><conditions><add input="{AllowedOrigins:{CAPTURED_ORIGIN}}" pattern=".+" /></conditions><action type="Rewrite" value="{C:0}" /></rule></outboundRules><rewriteMaps><rewriteMap name="AllowedOrigins"><add key="https://myserver.katyisd.org" value="https://myserver.katyisd.org" /></rewriteMap></rewriteMaps></rewrite></system.webServer></configuration>

Viewing all articles
Browse latest Browse all 2482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>