0

When I choose the same directory for .htaccess and .htpasswd, everything working fine.

But the situation below makes me sad.

I have one .htacces file in the root folder (johan) containing the code below.

AuthName "johan User"
AuthType Basic
AuthUserFile C:/wamp/www/johan/protectthisdir/.htpasswd
Require valid-user

.htpasswd is located at protectthisdir. When I try to access the johan suddenly getting authentication required message box. But I need it only at protectthisdir. How to do this? Please help.

Dinoop
  • 479
  • 4
  • 10

1 Answers1

0

You should put the .htaccess file in the folder you want to protect, and not the root folder in your case.

The .htpasswd file should not be accessible from a browser so putting it above the DocumentRoot folder is a good idea. So in C:\wamp in your case.

PS: It would be better to create a Virtual Host for your site to run in, in a completely different folder structure from the default wamp folders See this post for help on that

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • Hello @RiggsFolly. Thanks for the reply. It was a new information for me that how to create virtual host in wamp. But now I haven't the administration privilege to edit the host file. Have a good day :) – Dinoop Jun 05 '14 at 06:05
  • You can copy the hosts file to your desktop, edit it there and then copy it back. Otherwise launch your editor using the `Run as Administrator` menu option. – RiggsFolly Jun 05 '14 at 07:53