Redirecting root domain to TLS
Hello,
Currently http://ft.com
and https://ft.com
both redirect to http://www.ft.com
. As ft.com is now mostly served over https, and we have custom vcl to redirect back to http where appropriate, I would like http[s]://ft.com
to redirect to https://www.ft.com
to save an additional roundtrip.
The redirect appears to happen before entering into our vcl as, when curling, none of our debug headers show up, so I guess it’s not something we can tackle within our vcl. I’m also nervous of using the force TLS option in the fastly dashboards because there are scenarios where we do wish to redirect back to http.
Is there some way I can configure fastly to redirect the root domain to https://www?
-
hi @wheresrhys,
You can set this up using a synthetic http redirect in your service configuration. I'll include the documentation that provides the finer details, but the idea is as follows.
- Create a synthetic 301 Response
- Attach a condition that applies if the host header matches "ft.com"
- Create a new Response Header with the following details
- Set the
Destination
tohttp.Location
, and theSource
to"https://www.ft.com" + req.url
- Lastly, attach a response condition that executes the above in the event that the host header matches "ft.com" and the response status is a 301.
This will ensure that all requests to either
http://ft.com
orhttps://ft.com
get redirected tohttps://www.ft.com
Feel free to shoot us an email at support@fastly.com if you run into any troubles during implementation.
Cheers
Please sign in to leave a comment.
Comments
1 comment