How to Properly Redirect from HTTP to HTTPS?

June 9, 2025 3 answers
Asked by CoolCat123
I'm looking for the best way to redirect users from a public website (like example.com) to its secure version (https://www.example.com) when they enter either example.com or www.example.com in their browsers. Should this be handled through DNS redirection or should I configure something specifically on my web server?

Answers

WebSlinger99
I'd recommend setting up a reverse proxy in front of your actual servers, like NGINX, which can simplify your infrastructure. Using HSTS is also good, but for a solid hard redirect from HTTP to HTTPS, the proxy will help manage this efficiently.
Reply to this answer
TechWiz42
The best practice is to set up the redirection on your web server. You can enforce HSTS (HTTP Strict Transport Security) to help browsers remember to always use HTTPS. However, it won't assist the very first visit since it only applies after the initial connection. Check out the HSTS header documentation for more details!
Reply to this answer
ServerGuru88
Definitely go with server configuration for redirection. DNS itself canโ€™t handle this kind of redirect. If you're using web servers like Apache or NGINX, make sure to set up your redirect correctly. There are plenty of tutorials available that cover this.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions