I'm using IIS 10. I've a website that is reachable with subdomain1.domain.com and subdomain2.domain.com only on HTTPS protocol.
I would like to set up a rewrite rule only if request comes from subdomain2.domain.com where website should load the URL subdomain2.domain.com/la/signin. This last URL should be masked and not showed to the user.
I've tried a lot of rewrite rules and searched other suggestions on stackoverflow but every solutions did not worked for me, even without mask.
This one is just my last try without mask, but I've tried many other solutions:
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="https://subdomain2\.domain\.com$" />
<action type="Rewrite" url="{R:0}/la/signin" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
Any other suggestion?
Please try this rule. It will rewrite https://subdomain2.domain.com(/) to subdomain2.domain.com/la/signin.
<rule name="Redirect" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="la/signin" appendQueryString="true" logRewrittenUrl="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="subdomain2\.domain\.com" />
<add input="{HTTPS}" pattern="^on$" />
<add input="{URL}" pattern="^(/)?$" />
</conditions>
</rule>
Related
I want to write redirect rules in IIS 10. I googled it but could not found proper solution.
I have added some more scenarios.
https://testing.app.com/apptest should redirect to https://testing.app.com/apptest/account/login
https://testing.app.com/apptest/ should redirect to https://testing.app.com/apptest/account/login
https://test-apptest.testing.app.com/ should redirect to https://test-apptest.testing.app.com/account/login
https://test-apptest.testing.app.com should redirect to https://test-apptest.testing.app.com/account/login
Appreciated if someone can please help me with this.
What I tried so far is:
<rewrite>
<rules>
<rule name="Test1" stopProcessing="true">
<match url="apptest/login" />
<action type="None" />
</rule>
<rule name="login">
<match url="^apptest" />
<action type="Redirect" url="testing.app.com/apptest/login" appendQueryString="false" />
</rule>
</rules>
</rewrite>
You can try the rule below:
<rule name="test5" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="testing.app.com" />
<add input="{REQUEST_URI}" pattern="^/apptest$" />
</conditions>
<action type="Redirect" url="https://www.google.com/" appendQueryString="false" />
</rule>
I have a site that uses two characters in the URL path to determine the initial language e.g. https://my.company.net/Monitoring/gb displays in the English language. I want to setup a redirect for these two display the full culture code e.g. https://my.company.net/Monitoring/en-GB
This is the rule that I've tried:
<rewrite>
<rules>
<rule name="Monitoring gb rewrite" patternSyntax="ExactMatch" stopProcessing="true">
<match url="https://my.company.net/Monitoring/gb" />
<conditions />
<serverVariables />
<action type="Redirect" url="https://my.company.net/Monitoring/en-GB" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I expected https://my.company.net/Monitoring/gb to redirect to https://my.company.net/Monitoring/en-GB however this rule does not have any effect: the browser URL stays at https://my.company.net/Monitoring/gb.
How can I rectify this?
You could use below url rewrite rule.
<rule name="gb to en-gb redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="ww.sample1.com" />
<add input="{HTTPS}" pattern="on" />
<add input="{REQUEST_URI}" pattern="Monitoring/gb" />
</conditions>
<action type="Redirect" url="https://www.sample1.com/Monitoring/en-GB" />
</rule>
Note: use your hostname instead of the www.sample1.com.
The redirect failure was due to browser caching. The redirect works once the cache is cleared.
I have a nodejs application running on iis.
I have url rewrite rule which sends all request to a custom server.js page.
I want to add a new rule or modify the existing one so that a particular url /something reaches the iis and not the rule I have written.
My rule currently:
<rewrite>
<rules>
<rule name="node">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
Please help on this one.
<rule name="sendToNode">
<match url="/*" />
<conditions>
<add input="{URL}" pattern="/something$" negate="true" />
</conditions>
<action type="Rewrite" url="server.js" />
</rule>
i have two domains which share a similar link for a content that is /games-for-cats. What i want is redirecting the games-for-cats link to another link for FR website for instance but leaving the games-for-cats link untouched for other domain. I am using IIS and asp.net MVC so i tried doing this in the Web.Config but this isn't working. Below is what i tried to do.
<rules>
<rule name="Redirect rule pl for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(^(preprod\.test-website\.pl)(.*)$)" />
</conditions>
<action type="Redirect" url="{C:3}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/games-for-cats" value="/link-to-be-redirected" />
</rewriteMap>
</rewriteMaps>
Can someone guide to what the correct rewrite rule is.
Thanks.
You need to add an additional condition to your rule which will trigger your rule for a specific domain only:
<rule name="Redirect rule pl for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
<add input="{HTTP_HOST}" pattern="^preprod\.test-website\.pl$" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
URL Rewrite rule for redirecting from http to https:
<rewrite>
<rules>
<rule name="http to https" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
However, when you go directly to a subfolder like http://www.example.com/employees via an old bookmark or by typing the address into the browser, it doesn't redirect to https://www.example.com/employees but stays on http://www.example.com/employees.
Oddly enough, we have the same rewrite rules for a dev site, and it will redirect from http://dev.example.com/employees to https://dev.example.com/employees.
Very strange. Any ideas?
This is what I use - I add it to the applicationhost.config file, so it's at the global level. It's a little different then yours, I run many different sites and never have the issue you're describing doing it this way.
<rule name="Root Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{SERVER_PORT}" pattern="^80$" />
<add input="{HTTP_HOST}" pattern="example\.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>