Apache Protected Folder – How to

In normal Windows Installation
Path to your Apache Folder (C:\apache\ )
Path to your Apache Config Folder ( C:\apache\conf )

In Windows WampServer
Path to your Apache Folder (C:\wamp\bin\apache\apacheX.X.X )
Path to your Apache Config Folder (C:\wamp\bin\apache\apacheX.X.X\conf )

In Linux XAMPP
Path to your Apache Conf Folder ( /etc/httpd/conf/)

1.Open the httpd.conf file located in the Apache

2. Look for the word “AccessFileName .htaccess”
and change it to “AccessFileName ht.acl .htaccess”

3. this is how it should look like

AllowOverride All
Options None
Order deny,allow

4. Go to Apache bin directory and execute these commands

c:\apache\bin>htpasswd
(will show the available options)

c:\apache\bin>htpasswd -c -b passwd.txt username password
(A text file will be created holding the username and password, be careful if there are already passwords stored for other folder in your apache server using the same named convension)

If you execute a dir or ls in the apache\bin directory a password file name “psswd.txt” will be created

5. The next step is to create the .htaccess file in linux or ht.acl in Windows
The reason we added ht.acl file in htppd.conf is because in Windows machine its a hard thing to name a file that way. (the only solution I found was to download a file from my net hosting provider and edit it later for my use)

Here are the contents in the .htaccess or ht.acl file

AuthUserFile c:/apache/passwd.txt
AuthName "My Secured Folder"
AuthType Basic


require valid-user

6.Place this file in the root of each directory you want to secure

7. Restart Apache ( just in case)

8. This is the resulting modal authentication screen each time
you open the folder with your browser

htaccesspop

JUST IN CASE YOU MISUNDERSTOOD THIS IS A TUTORIAL FOR YOUR LOCAL APACHE SERVER.
If you have a hosting there are other more simple ways to do that. (in case you forgot your paying the hoster, ask them to do it for you)

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *