Skip to content

Instantly share code, notes, and snippets.

@WebDragon
Created November 15, 2023 00:45
Show Gist options
  • Save WebDragon/4114350d3c0a36c6c29ea205e9ece5c5 to your computer and use it in GitHub Desktop.
Save WebDragon/4114350d3c0a36c6c29ea205e9ece5c5 to your computer and use it in GitHub Desktop.
force https but allow validation from LetsEncrypt among others
# Force HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment