I have subdomain with an A record to my IIS Server:
sub.domain.com
The IIS server has a binding for sub.domain.com and a cert for *.domain.com
What we need is when someone goes to sub.domain.com it takes them to another site but masks the URL and keeps the SSL. The destination page has in its SAN cert sub.domain.com.
Tried a forward on Godaddy which works but it doesn't keep the SSL and we get cert issues. So thought was to point to our server to pass SSL and then redirect it. I tried a URL Rewrite but it's giving a 404.
URL Rewrite:
<rewrite>
<rules>
<clear />
<rule name="Pay Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www\.)?sub\.domain\.com$" />
</conditions>
<action type="Redirect" url="https://www.domain2.com/cgsdesktop/PaymentLanding/UniversalPortal" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I just need to know how to get this done.
How about this:
<rules>
<rule name="Pay Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^sub.domain.com$" ignoreCase="true"/>
<add input="{HTTP_HOST}" pattern="^www.sub.domain.com$" ignoreCase="true"/>
</conditions>
<action type="Redirect" url="https://www.domain2.com/cgsdesktop/PaymentLanding/UniversalPortal" appendQueryString="false" />
</rule>
</rules>
use sub.domain.com instead of sub\.domain\.com.
This article contains some useful recipes on IIS redirect/rewrite rules.
In order to mask the URL and keep the SSL in the browser bar, we need to create URL Rewrite action rules of URL Rewrite extension.
However, URL Rewrite action only supports to redirect the request to the same domain by default. We have to install the Application Request Routing extension when redirecting the request to another website.
https://www.iis.net/downloads/microsoft/application-request-routing
or we will get an Http 404 error.
See my preceding post for more details.
ASP.net URL Rewrite subdirectory to external URL
Feel free to let me know if there is anything I can help with.
Related
I am using URL rewrite to try and set up a rewrite from one site to the another site. I used URL re-write to set up this rule:
<httpRedirect enabled="false" destination="https://www.previdence.com" exactDestination="false" />
<rewrite>
<rules>
<rule name="SiteRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.previdence.com" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I have followed a couple of tutorials on setting this up and this is what should be set. So if I type in companyname.net it will redirect to https://www.companyname.com. If I type in https://www.companyname.net or https://companyname.net it goes to a 404.
Looking at the bindings for the old site there are bindings for PORT 443 and PORT 80 for www.companyname.net. I set the redirect in IIS for code 302, then I got URL rewrite as I explained above and I still get a 404 error.
I have an old url www.mydomain.com/customer/1. I changed that server to ww2 and it displays fine at ww2.mydomain.com/customer/1. On my new IIS 8.5 www server how can I put in a rewrite rule so if the user goes to www.mydomain.com/customer/1 they will redirect to ww2.mydomain.com/customer/1. I have tried numerous patterns in the Url Rewrite 2.0 module and nothing seems to work. All other www requests I do not want redirected, those stay on my new www server.
I you want to redirect a single path, /customer/1, then you should add this to Web.config on the www.mydomain.com server:
<rewrite>
<rules>
<rule name="Redirect 'www.mydomain.com/customer/1' to 'ww2.mydomain.com/customer/1'" stopProcessing="true">
<match url="^customer/1$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mydomain\.com$" />
</conditions>
<action type="Redirect" url="http://ww2.mydomain.com{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
If you wish to include additional paths, you can fiddle with the RegEx specified in the <match url="^customer/1$" /> tag.
I have a domain (www.example.com) with a subdomain (test.example.com)
I also have a domain pointer (www.pointer.com) pointing to www.example.com
What I would like to do is have anybody who types in www.pointer.com in the browser view test.example.com
<rule name="CanonicalHostNameRule1" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.pointer.com" />
</conditions>
<action type="Rewrite" url="test.example.com" />
</rule>
</rules>
but that just sends me to a HTTP Error 404.0 - Not Found page
Is there any way to pull this off?
This is running on IIS (windows) with php
You will need to change the action type to Redirect. A rewrite will only invoke a different resource on the server but will not change the URL in the browser. Other than that your rule looks good to me.
I have to redirect from a domain to another.
I try different ways to do this but it doesn't work.
Someone can tell me the right metod to do a redirect in web.config?
Without knowing the ways you tried, I would suggest setting up a Global URL Rewrite rule, you do this at the server level not the individual web site level.
These setting will be stored in the applicationhost.config (Server level), not the (web.config)
Below will redirect example2.com to example.com
<rule name="Redirect to new domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^example2\.com$" />
</conditions>
<action type="Redirect" url="https://www.eample.com/{R:0}" />
</rule>
I recently moved my website from http to https
My SSL certificate is for www.domain.com and not for domain.com, i.e. with www as prefix.
Now I facing an issue, when someone is accessing my website as http://www.domain.com it redirect to htts://www.domain.com without any issue as I have mentioned permanent redirect in web.config rewrite rules using following rules
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/mobile.asmx*" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
However, when some is trying http://domain.com I am getting certificate error as SSL certificate is for domain with www prefix.
What I need help with is that rewrite should work as follows:
if request is from http://www.domain.com then move it to https://www.domain.com
however, if request is from http://domain.com then also move it to https://www.domain.com.
Please help if possible as the issue is with live website.
I got it, all I need is to add www.
<action type="Redirect" redirectType="Permanent" url="https://www.{HTTP_HOST}/{R:1}" />