My document_root is /home/john/public_html
.
I need the URL example.com/subdir/index.php
to be handled by the file /home/john/public_html/index.php
.
This is what I put in /home/john/public_html/.htaccess
:
RewriteEngine on
RewriteRule ^.+$ index.php
i.e. internally redirect everything to index.php.
That worked perfectly fine until I added HTTP authentication to a subdirectory, like this:
In file /home/john/public_html/subdir/.htaccess
:
AuthType Basic
AuthName "Restricted subdir"
AuthUserFile "/home/john/.htpasswds"
require valid-user
Now when I request the URL example.com/subdir/index.php
, Apache ignores my rewrite rule and asks the client to enter username and password (the typical HTTP authentication dialog).
Why is this happening and how can it be solved?