Password Protect 1 index.php file only
Posted: Fri Nov 14, 2008 11:07 pm
I have been looking all over for a resolution to this problem, but I can't seem to find an answer anywhere...
What I want to do is password protect only 1 index.php file on my server, which resides in the home directory. Every other index.php that resides in other directories should be publicly accessible.
I tried using an .htaccess/.htpasswd combination with the following in my .htaccess file:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /directory/to/.htpasswd
AuthGroupFile /dev/null
<Files index.php>
require valid-user
</Files>
Unfortunately, this code is password protecting every single index.php file on my server. In addition, I have also tried using the password protect script at http://www.zubrag.com/scripts/password-protect.php, but unfortunately, this seems to password protect my index.html file as well in the home directory, which I can't have.
I have also tried creating a condition in the password-protect.php file from the above site (if $_SERVER['SCRIPT_NAME'] == '/index.html') { exit(); } else { rest of script goes here; }), but no matter what I do, it either password protects both my index.html and index.php in my home directory or neither of them.
Also tried scouring these boards, but couldn't find an answer to this specific problem.
If anyone knows how to only password protect the index.php file in my home directory only and no other file (including other index.php files in other directories), I would greatly appreciate it. Thank you.
What I want to do is password protect only 1 index.php file on my server, which resides in the home directory. Every other index.php that resides in other directories should be publicly accessible.
I tried using an .htaccess/.htpasswd combination with the following in my .htaccess file:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /directory/to/.htpasswd
AuthGroupFile /dev/null
<Files index.php>
require valid-user
</Files>
Unfortunately, this code is password protecting every single index.php file on my server. In addition, I have also tried using the password protect script at http://www.zubrag.com/scripts/password-protect.php, but unfortunately, this seems to password protect my index.html file as well in the home directory, which I can't have.
I have also tried creating a condition in the password-protect.php file from the above site (if $_SERVER['SCRIPT_NAME'] == '/index.html') { exit(); } else { rest of script goes here; }), but no matter what I do, it either password protects both my index.html and index.php in my home directory or neither of them.
Also tried scouring these boards, but couldn't find an answer to this specific problem.
If anyone knows how to only password protect the index.php file in my home directory only and no other file (including other index.php files in other directories), I would greatly appreciate it. Thank you.