Languages
[Edit]
EN

apache2 - redirect 80 to 443 (http to https)

5 points
Created by:
Root-ssh
121330

In this short article, we would like to show how to redirect traffic from HTTP to HTTPS using apache2 configs.

Quick solution (add following lines to /etc/apache2/sites-enabled/my-domain.com.conf):

# some configuration here ...

<VirtualHost *:80>
        ServerName my-domain.com
        RedirectPermanent / https://my-domain.com/
</VirtualHost>

# some configuration here ...

Hints:

  • change my-domain.com to your domain,
  • remove other VirtualHosts that uses my-domain.com with 80 port,
  • to enable my-domain.com site use: a2ensite my-domain.com.conf,
  • always after configuration changes, it is necessary to reload configurations or restart the apache2 server (use: systemctl reload apache2 or systemctl restart apache2).

Apache2

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join