Table of Contents

,

http to https redirect

Enable rewrite engine in non-ssl conf.

RewriteEngine on
RewriteCond %{SERVER_NAME} =yoursite.com [OR]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

In ssl conf add

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/yoursitename/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yoursitename/privkey.pem

Example of ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
	ServerName yoursite.com
        ServerAlias www.yoursite.com
 
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/yoursite
 
	<Directory /var/www/yoursite>
		AllowOverride All
		Options FollowSymlinks
	</Directory>	
 
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
 
	Include /etc/letsencrypt/options-ssl-apache.conf
	SSLCertificateFile /etc/letsencrypt/live/yoursite.com/fullchain.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/yoursite.com/privkey.pem
</VirtualHost>
</IfModule>

Tested on

See also

References