I have multiple domain names pointed to the same server (example.nl)
The example.my url should point to the content of example.nl/en, without having this url to appear in the adress bar. This is only really necessary for the homepage (due to google addwords issues).
To summarize, example.my should show the content of example.nl/en while showing example.my in the adress bar.
The current rule is giving me an error. Any tips?
<rule name="Redirect .my" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^.*example\.my$" />
</conditions>
<action type="Rewrite" url="http://www.example.nl/en/" />
</rule>
This seems to do the trick for me:
<rule name="redirect .my to /en" enabled="true" stopProcessing="true">
<match url="(^$)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.my" />
</conditions>
<action type="Redirect" url="http://www.example.my/en/{R:1}" appendQueryString="true" />
</rule>
Related
I have an aspx web app accessed via http://domain/web.aspx. This web app uses port 80 and http://domain:80/web.aspx works OK. I would like to redirect all calls to https://domain:82/web.aspx. I've tried using the rewrite rule
<rule name="HTTPS force" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*):80$" />
</conditions>
<action type="Redirect" url="https://localhost:82" appendQueryString="false" />
</rule>
in web.config in the same folder as web.aspx but this has no effect. What rewrite rule do I need to use?
You should use the following as input:
<rule name="HTTPS force" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>
Not sure if you want the :80 there in the URL? If so, it can be added to my example too. Taken from here: Web.config redirects with rewrite rules - https, www, and more.
Found this rule worked
<rule name="HTTPS force" enabled = "true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="http://domain/Web.aspx" />
</conditions>
<action type="Redirect" url="https://domain:82/Web.aspx"/>
</rule>
I am using IIS url rewrite rule to redirect from an IP Address to a domain name with the following rule.
<rule name="IPHit" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
Unfortunately, this results in an infinite loop redirect when I go to https://daart-qa.sandbox.aimsplatform.com/eds-daas.
How can I redirect from the IP address without having an infinite loop on dns entry?
Your rule will redirect 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas/eds-daas. Is that expected behavior?
May I know your only face this infinite loop when you access specific URL or all requests hitted by IP address. What loop URL did you see in web browser developer tool?
Post the symtptom of loop URL would help us find the root cause.
Or you need to redirect request 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas? If so you may need two rules side by side.
<rule name="IPHit" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" negate="true" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
<rule name="IP-HIT2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas{C:1}" />
</rule>
I have setup a url rewrite rule to redirect from one domain to another in case matching the condition. i have a site abc.aaa.com which should redirect to abc.bbb.com if url matches with *.aaa.com. When I hard code the action URL its working fine but using back reference its not working.
I am using IIS 8.5
Below are the rules.
This is not working. When I am doing this URL is showing http://abc.aaa.com/abc.bbb.com
<rule name="Redirect aaa.com" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*).aaa.com(.*)$" />
</conditions>
<action type="Redirect" url="{C:1}.bbb.com{C:2}" appendQueryString="false" />
</rule>
This is working
<rule name="Redirect aaa.com" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*).aaa.com(.*)$" />
</conditions>
<action type="Redirect" url="http://abc.bbb.com" appendQueryString="false" />
</rule>
I have tried the same pattern in rule pattern and same action without condition. thats also not working
<rule name="Redirect aaa.com" enabled="true" stopProcessing="true">
<match url="(.*).aaa.com(.*)$" />
<action type="Redirect" url="http://abc.bbb.com" appendQueryString="false" />
</rule>
I have found that {C:1} doesn't contain http:// part and seperated that in URL action . it's working fine.Below is the modified rule
Thanks Lex Li for the quick response
<rule name="Redirect aaa.com" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*).aaa.com(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}.bbb.com{PATH_INFO}" appendQueryString="true" />
</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>
I want to create a rewrite rule in IIS 8.5 so that the TLD in the url gets changed from .com to .net.
example:
from: http://sub.domain.com/index.aspx?test=123
to: http://sub.domain.net/index.aspx?test=123
At the moment I got something like this in my web.config but is doesn't seem to work:
<rule name="TLD" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?([a-z]*.)(domain)(.com)(/?.*)$" />
</conditions>
<action type="Rewrite" url="http://{C:2}{C:3}.net/{C:5}" />
</rule>
Any suggestions?
I was looking for the exact same problem and found this
<rule name="WWW" enabled="true" stopProcessing="true">
<match url=" (.*)"/>
<conditions >
<add input="{HTTP_HOST}" pattern="^(www\.)?example\.old$"/>
</conditions>
<action type="Redirect" url="h++p://example.com/{R:1}" redirectType="Permanent" />
</rule>
Found it here: ReWrite top-level domain (TLD)