User Tools

Site Tools


http to https redirect

Enable rewrite engine in non-ssl conf.

RewriteEngine on
RewriteCond %{SERVER_NAME} [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>
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/yoursite
	<Directory /var/www/yoursite>
		AllowOverride All
		Options FollowSymlinks
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
	Include /etc/letsencrypt/options-ssl-apache.conf
	SSLCertificateFile /etc/letsencrypt/live/
	SSLCertificateKeyFile /etc/letsencrypt/live/

Tested on

See also


wiki/http_https_redirect.txt · Last modified: 2021/07/09 10:02 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki