Skip to content

Instantly share code, notes, and snippets.

@llaumgui
Created February 21, 2018 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llaumgui/9698cd4f08f9f84510007a5d66b132dd to your computer and use it in GitHub Desktop.
Save llaumgui/9698cd4f08f9f84510007a5d66b132dd to your computer and use it in GitHub Desktop.
redirect all http queries to https and allow Let's encrypt challenge.
#
# HTTP: Let's encrypt + redirect on HTTPs
#
<VirtualHost _default_:80>
ServerAdmin yorktown@kulakowski.fr
### Let's encrypt
Alias /.well-known/acme-challenge/ /var/www/challenges/
<Directory "/var/www/challenges">
# Allow open access:
Require all granted
</Directory>
### Redirect to HTTPs
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
RewriteRule (.*) https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment