web analytics

Blog

Password protect Parent and Allow subdirectory using .htaccess

Tags: .htaccessparentpassword protectsub-directory

Published on: September 24, 2009 by George K.

Password protect Parent and Allow subdirectory  using .htaccess

Scenario:

To  password protect a directory htaccess password protect rules can be added in the directory

AuthUserFile /path/to/.htpasswd
AuthName "This is Hasten secret area"
AuthType Basic
require valid-user

To create .htpasswd file  use the following command

htpasswd -c .htpasswd  <user>

You will be prompted for password . Once it is done, the file will be created.

Now the directory is password protected.

Allow Subdirectory

The restrictions imposed on a parent directory will be applicable to the subdirectory too. To override this we need to specify it in .htaccess in the subdirectory. To disable password proptection on subdirectory , add the following in .htaccess

Allow from all
Satisfy Any


Category : Apache, cPanel, General, Howtos, Linux

George K.

George K.

George started his career in web hosting and Linux technical support in the year 2004 and is with SupportSages since 2009. He has keen interest in server optimizations, custom security solutions, hacked server recovery, cyber forensic and high availability fail over system design and implementation. George loves long drives and is passionate about art and literature.

You may also read:

Comments

Add new commentSIGN IN

  • Thanks, I was trying to figure this out for a while! Trying to allow access to a protected folder in Plesk. I simply created the .htaccess file like your example in the subfolder and it works. Thanks a lot.

  • Thanks, ur the only one that made any sense of this all.

  • is this possible protect sub folder and allow root ? please let me know

  • A simple access restriction in the subfolder using .htaccess should work.

Let's Connect

Get new updates

Categories

$0.000 items