EN
apache2 - redirect 80 to 443 (http to https)
5
points
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
VirtualHost
s that usesmy-domain.com
with80
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
orsystemctl restart apache2
).