<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite requests" enabled="true">
<match url="(.*)" />
<action type="Rewrite" url="https://site1.domain1.net/{R:0}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite outbound" enabled="true">
<match filterByTags="None" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<rule name="Rewrite cookie">
<match serverVariable="{HTTP_COOKIE}" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<preConditions>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Ok so I have a frontend server which is accessed by site2.domain2.com and all traffic to it should be url rewrote as site1.domain1.net this works pretty easily. My problem is the site running on site1.domain1.net writes a cookie with a bunch of non-standard values for the application it runs. I need to be able to change a value written to the cookie for logon purposes.
The line I need to target is below
https%3a%2f%2fsite1.domain1.net%2flgn%2fauth2%2fagent%2fsrms%2frefresh
It doesn't have any standard tag like url=value or host=value it's just the line above, I need to catch the site1.domain1.net part and change to site2.domain2.com but not having much luck.
You can see in the code at the top where I tried to do this, unsuccessfully as I don't know much about playing with the cookies. Suggestions?
I was close but wasn't using the right stuff, though a bunch more trial and error I managed to figure it out.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite requests" enabled="true">
<match url="(.*)" />
<action type="Rewrite" url="https://site1.domain1.net/{R:0}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite outbound" enabled="true">
<match filterByTags="None" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<rule name="Modify Cookie">
<match serverVariable="RESPONSE_Set_Cookie" pattern=".*" />
<conditions>
<add input="{R:0}" pattern="(.*)site1\.domain1\.net(.*)" />
</conditions>
<action type="Rewrite" value="{C:1}site2.domain2.com{C:2}" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Related
I have an existing web.config file to redirect a page titled privacy.asp to privacy (without the .asp extension). It works as it should.
I now have a client who had a file privacy.html and I want to send a httpResponseStatus of permanent, that being /privacy.
Here is what I tried but when pulling up the privacy.html it resolves with the .html extension but the actual page is that of the .asp.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="privacy.html">
<system.webServer>
<httpRedirect enabled="true" destination="/privacy/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<system.webServer>
<rewrite>
<rules>
<rule name="privacy" stopProcessing="true">
<match url="^privacy" />
<action type="Rewrite" url="privacy.asp" />
</rule>
</rules>
</system.webServer>
</configuration>
You could use below rewrite rule:
<rule name="privacy" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="privacy.html$" />
</conditions>
<action type="Redirect" url="privacy" appendQueryString="false" />
</rule>
<rule name="rewrite rule" stopProcessing="true">
<match url="privacy$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="privacy.asp" appendQueryString="false" logRewrittenUrl="true" />
</rule>
Note: do not forget to remove the location path and old URL rewrite rule.
Rregards,
Jalpa
before i start, i tried the search bar and i saw posts but these didnt really help me.
So im currently trying to foward my domain to force HTTPS and www.
so like when i type mydomain.de it forwards me to https://www.mydomain.de
this is my web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="http to https secure" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^(www.)?speargaming.de" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I dont see what i did wrong there.
In IIS 7, I want to force all pages to go to https by adding the following to my web.config but this causes infinite loop.
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I have tried to disable rule on all virtual directories/application as suggested here, http://blogs.msdn.com/b/kaushal/archive/2013/05/23/http-to-https-redirects-on-iis-7-x-and-higher.aspx, with no luck. Does anyone have any idea why? Thank you!
I have this simple rewrite, yet for some reason I cannot work out why it's not working:
<system.webServer>
<rewrite>
<rules>
<rule name="men-s-watches" stopProcessing="true">
<match url="(.*)/men-s-watches(.*)" />
<action type="Redirect" url="{R:1}/mens-watches" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
Hopefully someone can point out my noob mistake.
Normally in IIS7 url rewrite module is used and you can assign rules like this.
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="usr_rule">
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="men-s-watches">
<match url="^([0-9]+)/men-s-watches/([0-9]+)" />
<action type="Rewrite" url="men-s-watches/default.aspx?id={R:1}&p={R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
How can I configure Intelligencia.UrlRewriter in my ASP.NET web.config file to redirect all http://www.domain.com traffic to http://domain.com?
<if header="host" match="www.yoursite.com" />
<redirect url="^(.+)$" to="http://yoursite.com$1" />
</if>
Thanks, dana, but here's what I ended up adding to my web.config file...
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.mysite.com$" />
</conditions>
<action type="Redirect" url="http://mysite.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>