I'm trying to do a HTTP to HTTPS redirect on a GoDaddy web hosting platform. I have the Windows hosting platform and I'm editing the web.config file. There are multiple domains under this hosting account, and I'm trying to do the redirect for only ONE domain and its subdomains.
Example:
- 5 domains:
domain1.example
,domain2.example
, etc... and each domain may have subdomains
Desired behaviour:
*.domain1.example
redireced tohttps://*.domain1.example
(with or without www)- include a wildcard in front of the domain, to handle any sub-domains
This is what I started with, which will redirect every domain from HTTP to HTTPS, and it works properly:
<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>
Now I tried to make it for a specific domain only, but I really have no idea how to write this myself. Instead I have put together some stuff I found online. I find all the +?\
and A-Za
quite confusing.
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(https?:\/\/(.+?\.)?domain1\.example(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
But this results in a 500 (internal server) error.