{"id":36,"date":"2009-09-18T14:05:39","date_gmt":"2009-09-18T18:05:39","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=36"},"modified":"2013-03-20T08:38:59","modified_gmt":"2013-03-20T12:38:59","slug":"password-protecting-a-directory","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/password-protecting-a-directory","title":{"rendered":"Howto: Password Protect a directory using .htaccess"},"content":{"rendered":"<blockquote><p><strong>How to Password Protect a Directory using .htaccess?<\/strong><\/p><\/blockquote>\n<p>You may need to password protect a directory in order to limit the sharing of files under it OR may need to protect a private area. You can password protect a directory using a .htaccess file which has to be placed under a directory which needs to be protected.<\/p>\n<p>Create a .htaccess file<\/p>\n<blockquote><p><strong><span style=\"color: #0000ff;\">vi \/home\/username\/.htaccess<\/span><\/strong><\/p><\/blockquote>\n<p>Once created, add the following lines to it:<\/p>\n<blockquote><p><strong><span style=\"color: #0000ff;\">AuthUserFile \/home\/username\/.htpasswd<br \/>\nAuthName &#8220;Private Area&#8221;<br \/>\nAuthType Basic<br \/>\nrequire valid-user<\/span><br \/>\n<\/strong><\/p><\/blockquote>\n<p>where, &#8216;username&#8217; is the actual username of your domain. Now, <strong>create a .htpasswd file <\/strong> under the \/home\/username\/ directory.<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>vi \/home\/username\/.htpasswd<\/strong><\/span><\/p><\/blockquote>\n<p>In order to grant access to the directory for specific users, you need to place all the users along with their passwords in the below format:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>username1:encryptedpassword<br \/>\nusername2:encryptedpassword<\/strong><\/span><\/p><\/blockquote>\n<p>There is no limit in adding users to this file, just make sure each user should be on a separate line and you can encrypt passwords using any available tool on the internet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Password Protect a Directory using .htaccess?<br \/>\nYou may need to password protect a directory in order to limit the sharing of files under it OR may need to protect a private area. You can password protect a directory using a .htaccess file which has to be placed under a directory which needs to be protected.<br \/>\nCreate a .htaccess file<br \/>\nvi \/home\/username\/.htaccess<br \/>\nOnce created, add the following lines to it:<br \/>\nAuthUserFile \/home\/username\/.htpasswd<br \/>\nAuthName &#8220;Private Area&#8221;<br \/>\nAuthType Basic<br \/>\nrequire valid-user<\/p>\n<p>where, &#8216;username&#8217; is the actual username of your domain. Now, create a .htpasswd file  under the [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[627,53,625,626,624],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":4,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":449,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions\/449"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}