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
how to set ht docs permissions?
Moderator: General Moderators
-
scotty4444
- Forum Newbie
- Posts: 2
- Joined: Mon Dec 29, 2008 3:22 am
Re: how to set ht docs permissions?
1. Create a .htaccess file in your dir with ultra secret hidden files, and put this in it:
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.
Code: Select all
AuthUserFile "/home/some_random_dir/.htpasswd"
AuthName "Admins Only!"
AuthType Basic
require valid-user3. 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.
-
scotty4444
- Forum Newbie
- Posts: 2
- Joined: Mon Dec 29, 2008 3:22 am
Re: how to set ht docs permissions?
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)
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)