.htaccess to require passwords, block IPs, and require HTTPS

I've got an .htaccess file, and everything works except the redirection to HTTPS. If I remove everything else, that part works, but when it's all there together, it fails.

Thanks in advance for any help you can offer!

require a password

AuthUserFile /blah/blah/blah/.htpasswd

AuthGroupFile /dev/null

AuthName Locked_Down

AuthType Basic

require valid-user

order deny,allow

allow from office network:

allow from x.y.z

allow from my home office IP:

allow from a.b.c.d

deny from everyone else:

deny from all

force HTTPS

this worked in tests in isolation, but not here:

RewriteEngine On

RewriteCond %{HTTPS} !=on

RewriteRule .* https://%{SERVERNAME}%{REQUESTURI} [R,L]

RewriteEngine Off

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct