Protect your webserver : .htaccess + .htpasswd

Hi all

in this topic we going to know how to protect the folders on Apache web server with a username&password in direct n easy steps :

before we start we have here to type of files :

.htaccess : the configuration files.. here we write the Apache instructions
.htpasswd : here we store the passwords and usernames

you can download these files from the link below
http://www.easywamp.com/download/htaccess.htpasswd.zip

1- paste this code in .htaccess file :

  1. AuthName "Easywamp Server"
  2. AuthType Basic
  3. AuthUserFile C:\EasyWAMP\www\.htpasswd
  4. Require valid-user

AuthName "Easywamp Server"
write any thing you like between quotes

AuthUserFile C:\EasyWAMP\.htpasswd
full path to .htpasswd

very important note : don't put .htpasswd inside public_html or www folder .
for security reasons .and it's not necessary that .htaccess and .htpasswd should be in the same folder .

move .htaccess to any folder you want to keep it safe.

for Example

www
|\____phpmyadmin
|\____phpbb
.\____admin

-if you move .htaccess into www this will protect all files and sub folders under www
-if you move .htaccess into admin folder this will protect all sub folders under admin , but not phpbb and phpmyadmin .

2- write your user name and password in .htpasswd
like this :

username:password

root:password
admin:admin

3 - try to access that folder where the .htaccess is located .

discuss this article in our forum
http://www.easywamp.com/forum/viewforum.php?f=2

Syndicate

Syndicate content

User login

Who's online

There are currently 0 users and 3 guests online.