{"id":97,"date":"2008-06-16T07:25:54","date_gmt":"2008-06-16T15:25:54","guid":{"rendered":"http:\/\/www.zenutech.com\/kb\/?p=97"},"modified":"2012-06-21T07:50:32","modified_gmt":"2012-06-21T15:50:32","slug":"setting-up-a-password-protected-directory","status":"publish","type":"post","link":"https:\/\/www.zenutech.com\/kb\/article\/setting-up-a-password-protected-directory\/","title":{"rendered":"Setting up a password protected directory"},"content":{"rendered":"<p>There are two steps to protecting a folder with a .htaccess file.<\/p>\n<h2>Step 1:<\/h2>\n<p>Using Notepad (or another text editor), create a file called<strong> .htaccess<\/strong> (please note the period). Enter the following text in the file:<\/p>\n<blockquote>\n<pre>\r\nAuthUserFile [HOME PATH]htpasswd\/[FOLDER]\r\nAuthName \"Please enter your username and password\"\r\nAuthType Basic\r\n\r\nrequire valid-user\r\n<\/pre>\n<\/blockquote>\n<p>Replace [HOME PATH] with your Zenutech account&#8217;s home folder path.  To find your Zenutech account&#8217;s home folder path, login to the Zenutech Control Panel and on the main page look for &#8216;Home Path&#8217; under the &#8216;Web Development&#8217; box.  If you are already logged into the Zenutech Control Panel and want to access the main page, click &#8216;Zenutech Control Panel&#8217; icon in top left corner.<br \/>\nThe [HOME PATH] should look something like <strong>\/home\/youruser\/<\/strong>  and the entire &#8216;AuthUserFile&#8217; filepath should look something like <strong>\/home\/youruser\/htpasswd\/folder_to_protect_as_filename<\/strong><br \/>\nYou will need to create the htpasswd\/ folder as mentioned below in this article.<\/p>\n<p>Replace [FOLDER] with the name of the folder you are protecting. For example, if you want to protect www.demo123.com\/members, then [FOLDER] should be changed to &#8216;members&#8217;.  If you want to protect a subfolder, such as www.demo123.com\/members\/subfolder7 , then [FOLDER] should be named &#8216;subfolder7&#8217;.<\/p>\n<p>Save this .htaccess file; it must be called &#8216;.htaccess&#8217; with no file extension after the name.  Then upload the file <b>into the folder you want to protect<\/b>. Now when you visit that folder, you will be asked for a username. There still isn&#8217;t one setup, though, so keep reading!<\/p>\n<h2>Step 2:<\/h2>\n<p>Begin by creating a file with the same name as the [FOLDER] from above that you want protected. This file will hold the usernames and passwords that have access to the folder.<\/p>\n<p>We now need to created encrypted password(s) to store in this file. This is accomplished with a tool called &#8216;htpasswd&#8217;, which is available for free on a number of webpages, such as <a href=\"http:\/\/www.htaccesstools.com\/htpasswd-generator\/\" target=\"_blank\"><strong>this one<\/strong><\/a>. Run each username and password through the tool, and then enter the username with the encrypted password into the file. For example, with username &#8216;mary&#8217; and password &#8216;blackpin123&#8217;, enter this into the file:<\/p>\n<blockquote><p>mary:n\/KK81Nclh0zQ<\/p><\/blockquote>\n<p>Each user should be on a seperate line, the semi-colon (:) is not part of the encrypted password; it is just there to indicate to the server that the username is on the left and the encrypted password is on the right. On the server, you will need to create a folder in the root of your FTP structure(i.e. \/home\/youruser\/) named &#8216;htpasswd&#8217;. Now you can upload the new file to this folder.<\/p>\n<p>All that remains is for you to try it out!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using an .htaccess file to password protect a folder<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[161],"tags":[168,225,143,166,27,224,167],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-site-management","tag-authuserfile","tag-folder","tag-htaccess","tag-htpasswd","tag-password","tag-protect","tag-username"],"_links":{"self":[{"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":7,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/posts\/97\/revisions\/232"}],"wp:attachment":[{"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zenutech.com\/kb\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}