Created
November 4, 2019 16:59
-
-
Save lyquix-owner/03e03f092c614e8809d4a2258cd620b5 to your computer and use it in GitHub Desktop.
Redirect to preferred domain, force SSL, and require HTTP Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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