how to set ht docs permissions?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
scotty4444
Forum Newbie
Posts: 2
Joined: Mon Dec 29, 2008 3:22 am

how to set ht docs permissions?

Post 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
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: how to set ht docs permissions?

Post 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.
scotty4444
Forum Newbie
Posts: 2
Joined: Mon Dec 29, 2008 3:22 am

Re: how to set ht docs permissions?

Post by scotty4444 »

ty that helped me a bunch :D
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)
Post Reply