Skip to content

Instantly share code, notes, and snippets.

@lyquix-owner
Created November 4, 2019 16:59
Show Gist options
  • Save lyquix-owner/03e03f092c614e8809d4a2258cd620b5 to your computer and use it in GitHub Desktop.
Save lyquix-owner/03e03f092c614e8809d4a2258cd620b5 to your computer and use it in GitHub Desktop.
Redirect to preferred domain, force SSL, and require HTTP Auth
# Redirect domain and force SSL #
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$ [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
<If "%{HTTPS} == 'on'">
# Password Protect Directory #
AuthUserFile /srv/www/example.com/.htpasswd
AuthName "Enter username and password"
AuthType Basic
Require valid-user
</If>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment