I've got a site in IIS that has 2 domain bindings associated with it:
- mysite.com
- internal.mysite.com
The users inside the network user the internal.mysite.com and outside uses mysite.com.
I'd like to setup a canonical domain name rule so the outside users going to mysite.com are redirected to the www version (www.mysite.com).
But, when I setup the redirect, the internal.mysite.com users are also directed to the www site.
Is it possible to create an exception so that the internal.mysite.com domain is NOT redirected? Or, do I have to create a separate site in IIS?
Thanks!
It is possible, your rule should be like that:
<rule name="Redirect example.com to www" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" />
</rule>
You just need to replace example.com with your actual domain name
Related
I've got a GoDaddy multi website hosting account and now that I've implemented SSL I want all those domains that have SSL to now redirect to https. GoDaddy says the web.config needs to be modified but they have no examples on how to do this for multiple domains.
I've tried the following code which works for the main domain (domainA) on the hosting account but then it messes up all the URLs for all the other domains hosted on that account. For example http://domainA.com redirects to https://domainA.com but with this code implemented http://domainB.com redirects to https://domainB.com/domainB/ -- domainB being the sub-folder that the other domain files are stored.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Try https://{HTTP_HOST}{REQUEST_URI} in your action.
Also I'd use temporary not permenant redirects while testing. Your browser may cache a bad redirect which can be very frustrating so make sure to clear your cache or use an in-private browser window to test changes.
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 need to remove WWW. from all my URLs on route 53. I have a web.config rewrite rule on my website that works with my Azure VMs but when converting to webapps it is not allowed. A mistake in the past informed users that their personal website was www.john.domain.com or www.jane.domain.com. With the Rewrite rule on it works going to VMs in azure but not to Webapps. I am looking to remove the extra www. from all url requests. I am using Route 53 for DNS and I have a Redirect rule for Naked DNS domain.com already to go to www.domain.com but I would like to have another redirect or rewrite that works like the web.config rule.
<rule name="Remove www from 4th level" stopProcessing="true">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.([^\.]+\.[^\.]+\.[^\.]+)$"/>
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" statusCode="200" statusReason="Ok"/>
</rule>
You're missing the http/https from your pattern. Your conditions should look more like:
<conditions>
<add input="{HTTP_HOST}" pattern="^http://www\.([^\.]+\.[^\.]+\.[^\.]+)$"/>
<add input="{HTTP_HOST}" pattern="^https://www\.([^\.]+\.[^\.]+\.[^\.]+)$"/>
</conditions>
I have a subdomain (subdomain.example.com) that I want to redirect it to this Url format on my website https://example.com/some-web-page.
I created an empty site in IIS, the site only contains a web.config file with this rule:
<rule name="subdomain.example.com Redirect" stopProcessing="false">
<match url="^\/?$" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*subdomain\.example\.com.*" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://example.com/some-web-page/{R:0}" />
</rule>
Now, subdomain.example.com is redirecting as it should but https://subdomain.example.com is taking me to https://example.com home page and the address bar shows an error saying "The identity of the website has not been verified. Server's certificate does not match the Url."
I should also mention that I have purchased an additional certificate for https://subdomain.example.com.
How can I make this https redirect to work in such scenario?
I configured a custom domain for my Azure Web Site using CNAME records.
Everything works fine, except for the fact that I can access my site using both *.azurewebsites.net and *.com.
Isn't this a SEO issue, and can it be avoided so that I get *.com in both cases?
You can try with simple url rewrite rule in your web.config file:
<system.webServer>
<rewrite>
<rules>
<rule name="MyHostNameRule">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://domain.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Basically, it says that if request host doesn't match specified pattern, just rewrite it to domain.com/... If you have access to the IIS, you can use Url Rewrite module there, where this code can be created through a wizard.
One hint: when developing app and testing on localhost:port, it will rewrite url. To avoid that, put this rewrite rule in Web.Release.Config, and of course deploy your app to Azure WebSite in Release mode! Only thing you need is add xdt:Transform to rewrite element:
<rewrite xdt:Transform="Insert">