I have a password protected directory at example.com/staging.
If I enter example.com/js I get a folder listing.
But if I enter example.com/staging, I get a 404 error page generated by the Laravel site at example.com (not example.com/staging), rather than a password box. Why is this?
Here is my .htaccess file in the public_html folder (the home directory) at example.com:
AddType application/x-httpd-php70 .php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
And my .htaccess file at example.com/staging:
AuthType Basic
AuthName "Staging"
AuthUserFile "/home/example/.htpasswds/public_html/staging/passwd"
require valid-user