I want to redirect specific URLs permanently to other domains.
<rule name="URL Test" enabled="true" stopProcessing="true">
<match url="^en/career/jobs$" />
<conditions logicalGrouping="MatchAny">
</conditions>
<action type="Redirect" url="https://www.example.com/newjobs" appendQueryString="false" redirectType="Permanent" />
</rule>
It works when I use https://source.com/en/career/jobs
but when I add a slash in the end (https://source.com/en/career/jobs/), it doesnt work.
How can I accept both variants in the match url ?
You just need to change your parameters to match both en/career/jobs/ and en/career/jobs. You can use the following rules as a reference:
<rule name="URL Test" enabled="true" stopProcessing="true">
<match url="^en/career/jobs(.*)$" />
<action type="Redirect" url="https://www.example.com/newjobs" appendQueryString="false" redirectType="Permanent" />
</rule>
Related
I have the following URL
https://www.abcsite.com/?data=w35VTqIaVXWfi4GmESj8EGCG1cdF2aT%2BUF3D?utm_source=external%20system&utm_campaign=external%20system&utm_medium=EX.com&utm_content=MMB
which has extra ? at the end. which I Would like to remove and replace with "&"
I am using following rule but it is not working. can you review this and tell me what I am doing wrong.
<rewrite>
<rules>
<rule name="fixdata" stopProcessing="true">
<match url="\?(.*)\?(.*)$" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}&{R:2}" />
</rule>
</rules>
</rewrite>
Thanks.
You rule should be like this:
<rule name="fixdata" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{QUERY_STRING}" pattern="(.*)\?utm_source(.*)$" />
</conditions>
<action type="Redirect" url="{R:0}?{C:1}&utm_source{C:2}" appendQueryString="False" />
</rule>
Your rule didnt work, because <match url= contains path without query string. You need to create additional condition to match query string with your regexp pattern
Can someone explain why this rule is not working? I want a permanent redirect when the querystring below is in the url
<rule name="Telephony Document Lib Redirect" stopProcessing="true">
<match url="(.*)?RootFolder=%2FTechnology%2FShared%20Documents%2FTelephony(.*)" />
<action type="Redirect" url="https://{HTTP_HOST}/sites/teams/Telephony" appendQueryString="false" redirectType="Permanent" />
</rule>
The querystring is separate from the url, and should be matched using a condition, like so:
<rule name="Telephony Document Lib Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{QUERY_STRING}" pattern="RootFolder=%2FTechnology%2FShared%20Documents%2FTelephony(.*)" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/sites/teams/Telephony" appendQueryString="false" redirectType="Permanent" />
</rule>
I want all request that look like:
(www.)mydomain.com/belgium(/*)
to be redirected to:
(www.)mydomain.be
The path and querystring after /belgium/ need to be included:
www.mydomain.com/belgium/page1/page11?filter=yes
Needs to become
www.mydomain.be/page1/page11?filter=yes
<rule name="Rewrite" enabled="true">
<match url="www.mydomain.com/belgium" />
<conditions logicalGrouping="MatchAll" >
<add input="{QUERY_STRING}" pattern="(.+)"/>
</conditions>
<action type="Redirect" url="www.mydomain.be?{C:1}" appendQueryString="true" />
</rule>
<rule name="Rewrite" enabled="true">
<match url="www.mydomain.com/belgium/{.*)" />
<action type="Redirect" url="www.mydomain.be{R:1}" appendQueryString="true" />
</rule>
You can write additional rule to handle www part of the link.
I write this out of my head so it is not correct but I believe it should give you a hint.
Why isn't this rule working when I go to a browser with the URL rewrite module?
It works on the regex tester with the url rewrite module.
I even put it at the top of all my rules.
Example url: organizations/51/middle-tennessee-basketball-showcases-basketball-tournaments?page=1
Rewrite rule:
<rule name="Organization Redirect" stopProcessing="true">
<match url="^organizations/(.*)-basketball-tournaments\?page=1$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>
Your rule should be as following:
<rule name="Organization Redirect" stopProcessing="true">
<match url="^organizations/(.*)-basketball-tournaments$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^page=1$" />
</conditions>
<action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>
You should not check the query string (here page=1) in the url test but in the conditions section.
I would like to match exactly https://internet.dev.local/KYR url (without / into end) and redirect or rewrite to https://internet.dev.local/KYR/ (with /).
I am trying the following rule but it matches other URLs as well e.g. https://internet.dev.local/KYR/Admin/Form/Default.aspx?signup=false, which is wrong.
so how can I achieve this?
<rule name="Static redirect" patternSyntax="ExactMatch" stopProcessing="true">
<match url="https://internet.dev.local/KYR" negate="true" />
<conditions>
</conditions>
<action type="Redirect" url="/Login/?ReturnUrl=/Member/KYR/" redirectType="Permanent" />
</rule>
If you need to test the host and protocol you have to put it in the conditions, not in the global rule.
Following your example, it would be as follow:
<rule name="test" patternSyntax="ExactMatch" stopProcessing="true">
<match url="KYR" />
<action type="Redirect" url="/KYR/" redirectType="Permanent" />
<conditions>
<add input="{HTTP_HOST}" pattern="internet.dev.local" />
<add input="{HTTPS}" pattern="on" />
</conditions>
</rule>
I have changed the url in the action because your question says:
redirect or rewrite to https://internet.dev.local/KYR/ (with /).
EDIT:
To get it to work on any host (with or without SSL), just remove the conditions:
<rule name="test" patternSyntax="ExactMatch" stopProcessing="true">
<match url="KYR" />
<action type="Redirect" url="/KYR/" redirectType="Permanent" />
</rule>