I am trying to re-write a URL from this address:
https://merchant.test-01.mysite.co/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD
To this address:
https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD
I try this:
<rule name="test01Generic" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
</conditions>
<action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}" redirectType="Found" />
</rule>
With this result:
https://mysite.co/nz/test-01/merchant?amount=69.90®ister_id=12¤cy=NZD
Where payment-gateway/vend is missing
And this
<rule name="test01Generic" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
</conditions>
<action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{REQUEST_URI}" redirectType="Found" />
</rule>
With this result:
https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD&amount=69.90®ister_id=12¤cy=NZD
The query parameters double up.
Any ideas on what am I missing?
Please modify {REQUEST_URI} to {URL} and leave appendQueryStrin to true, then it would work.
<rule name="test0Generic" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
</conditions>
<action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{URL}" appendQueryString="true" redirectType="Found" />
</rule>
I was able to work it out, I had to change {REQUEST_URI} to {PATH_INFO}
<rule name="test01Generic" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
</conditions>
<action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{PATH_INFO}" redirectType="Found" />
</rule>
Now when the address bellow is called:
https://merchant.test-01.mysite.co/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD
I'm redirecting to this address:
https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD
Related
I would like to replace
https://web1.domain.org/cwweb/LauncherInterface.aspx?host=https://web1.domain.org/
with
https://web2.domain.org/cwweb/LauncherInterface.aspx?host=https://web2.domain.org/
and keep everything else after it.
e.g. "https://web2.domain.org/xxxxx/LauncherInterface.aspx?host=https://web2.domain.org/xxxxx&thisid=zzzz"
This is what I have tried:
<rewrite>
<rules>
<rule name="redirect app" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="web1.domain.org" />
</conditions>
<action type="Redirect" url="https://web2.domain.org/cwweb/LauncherInterface.aspx?host=https://web2.domain.org/{R:1}" />
</rule>
</rules>
</rewrite>
This is what it displays: ""https://web2.domain.org/xxxxx/LauncherInterface.aspx?host=https://web1.domain.org/xxxxx&thisid=zzzz"
The second domain name doesn't change.
I pretty much a noob with this. Any assistance would be appreciated.
You can try this rule:
<rule name="test" stopProcessing="true">
<match url="^cwweb/LauncherInterface.aspx$" />
<conditions>
<add input="{HTTP_HOST}" pattern="web1.domain.org" />
<add input="{QUERY_STRING}" pattern="(.*)web1(\.domain\.org.*)" />
</conditions>
<action type="Redirect" url="https://web2.domain.org/{R:0}?{C:1}web2{C:2}" appendQueryString="false" />
</rule>
Can I redirect all page of my site to new site?
<rule name="301 Redirect 1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://take-car.ru{REQUEST_URI}" redirectType="Permanent" />
</rule>
but its dont work
<rule name="301 Redirect 1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="omegaprokat.ru" />
</conditions>
<action type="Redirect" url="https://take-car.ru{REQUEST_URI}" redirectType="Permanent" />
</rule>
When I add the following rule to the redirection file:
<rule name="To Lowercase" enabled="true" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/Images/" negate="true" />
<add input="{REQUEST_METHOD}" pattern="GET" ignoreCase="true" />
</conditions>
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
<rule name="Redirect to WWW">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^foo.com$" />
</conditions>
<action type="Redirect" url="http://www.foo.com/{R:0}" redirectType="Permanent" />
</rule>
And attempt to open webiste "Foo.com" watching network behaviour I can see that it's first redirected (301) from "https://Foo.com" to "http://foo.com" and then from "http://foo.com" back to "https://foo.com" with status 302.
Is there a way to modify this rule to make just one redirection?
Based on your answers in comments, you can just simply specify the domain name in your rules to avoid multiple redirects. For example:
<rule name="To Lowercase" enabled="true" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/Images/" negate="true" />
<add input="{REQUEST_METHOD}" pattern="GET" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.foo.com/{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
<rule name="Redirect to WWW">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^foo.com$" />
</conditions>
<action type="Redirect" url="https://www.foo.com/{R:0}" redirectType="Permanent" />
</rule>
I am trying to redirect all http://thesite.com, http://www.thesite.com, https://thesite.com to https://www.thesite.com. But I don't have the pattern correct. What am I doing wrong?
<rewrite>
<rules>
<rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
I found the solution:
<rule name="Redirect non-www OR non-https to https://www">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^thesite.com$" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.thesite.com/{R:0}" redirectType="Permanent"/>
</rule>
I have 2 domains pointing to the same Umbraco application:
oldexample.com
newexample.com
I want my application to change the URL from:
oldexample.com/...
TO
newexample.com/...
when people visit the oldexample.com.
In my web.config, I've placed this, but to no effect:
<rewrite>
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^oldexample.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
<add input="{HTTP_HOST}" negate="true" pattern="localhost" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
What am I doing wrong?
// The application is hosted in Azure web sites. And both URLs are hostnames assigned to the site.
<rewrite>
<rules>
<rule name="Redirect oldexample.com to newexample.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.oldexample\.com$" />
<add input="{HTTP_HOST}" pattern="^oldexample\.com$" />
</conditions>
<action type="Redirect" url="http://www.newexample.com/{R:1}" />
</rule>
</rules>
</rewrite>