I have created a simple CSM website using core PHP. I have placed my fronted code in root directory i.e. public_html
and admin code inside admin directory i.e. public_html/admin.
I want to password protect my admin part with htpassword. Below is my code for admin/.htaccess
file.
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/public_html/admin/.htpasswd
ErrorDocument 401 /admin
Require valid-user
I have also added redirect from http to https in root .htaccess
file as below
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
htpassword for admin only working if I will remove above code from root .htaccess file.
Anything wrong is there?