user10016609
user10016609

Reputation: 11

web.config https redirect for multi-domain hosting

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>

Upvotes: 1

Views: 385

Answers (1)

MisterSmith
MisterSmith

Reputation: 3624

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.

Upvotes: 1

Related Questions