Page 1 of 1
how to set ht docs permissions?
Posted: Mon Dec 29, 2008 3:25 am
by scotty4444
I just created a website and want to set some permission to "admin only" files, what are the steps in order to make these files only accessable, viewable by admins. These files will be located inside the Htdocs
Ty and will appreciate help on this one
Re: how to set ht docs permissions?
Posted: Mon Dec 29, 2008 4:22 am
by Apollo
1. Create a .htaccess file in your dir with ultra secret hidden files, and put this in it:
Code: Select all
AuthUserFile "/home/some_random_dir/.htpasswd"
AuthName "Admins Only!"
AuthType Basic
require valid-user
2. Encrypt your password with PHP's
crypt function or do it somewhere online, for example
here.
3. Create a .htpasswd file in some_random_dir with one line like this:
scotty4444:EnCrYpTeDpAsSwOrD
Now you can access that dir only with username "scotty4444" and the password you used in step 2.
The some_random_dir should preferably be somewhere outside your htdocs dir. Note that you need an absolute path on your server in the .htaccess file.
Re: how to set ht docs permissions?
Posted: Mon Dec 29, 2008 8:30 am
by scotty4444
ty that helped me a bunch

but is there anyway i can use a encripted password, in just 1 php file?
like if my username and password was
$username = "username";
$password = "password";
could i make the $username and/or $password encripted in just 1 php file (my config.php file)