Answer the question
In order to leave comments, you need to log in
Is it possible to set the execution order of scripts in the .htaccess file?
Good afternoon!
Set a password for a folder on the server. I put the .htaccess file with the contents in the folder itself:
# Редирект всех страниц с http:// на https://
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# И только теперь просим ввести пароль
AuthType Basic
AuthName "Пожалуйста, авторизуйтесь"
AuthUserFile полный/путь/на_сервере/.htpasswd
require valid-user
Answer the question
In order to leave comments, you need to log in
If I'm not mistaken, if else conditions are supported, something like this
<If "%{HTTPS} == 'on'">
AuthName "Files are protected, enter your normal website email and password"
AuthType Basic
AuthUserFile /home/sites/mysite.co.uk/.htpasswd
Require valid-user
</If>
<Else>
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</Else>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question