Skip to content

Instantly share code, notes, and snippets.

@martiuh
Created December 15, 2018 15:49
Show Gist options
  • Save martiuh/f8ae6e49b5d6e2ddcb389c7e25c57127 to your computer and use it in GitHub Desktop.
Save martiuh/f8ae6e49b5d6e2ddcb389c7e25c57127 to your computer and use it in GitHub Desktop.
Simple .htaccess file for ensure htttps on apache a2hosting server
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ https://example.com.mx/$1 [R=301,L]
RewriteCond %{HTTPS} off
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)?$
RewriteRule ^(.*)$ https://example.com.mx/$1 [L,R=301]
RewriteRule ^$ http://127.0.0.1:49159/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49159/$1 [P,L]
#Prevent Apache from serving hidden files
<FilesMatch "^\..+">
Order allow,deny
Deny from all
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment