{"id":17856,"date":"2024-05-23T15:54:03","date_gmt":"2024-05-23T15:54:03","guid":{"rendered":"https:\/\/hostvento.com\/kb\/web-hosting\/how-to-protect-a-directory-with-a-password\/"},"modified":"2024-06-17T05:34:47","modified_gmt":"2024-06-17T05:34:47","slug":"how-to-protect-a-directory-with-a-password","status":"publish","type":"docs","link":"https:\/\/www.hostvento.com\/kb\/docs\/hosting-faqs\/how-to-protect-a-directory-with-a-password\/","title":{"rendered":"How to Protect a Directory with a Password?"},"content":{"rendered":"\n<p>With cPanel, directories may be password-protected. By doing this, every file inside the password-protected folders is secured.<\/p>\n\n\n\n<p>Note: Individual files cannot be protected by cPanel; only folders can. A protected directory is where you may find any file that needs to be secured. Furthermore, folders that are accessible locally or via FTP, SFTP, or Web Disk are not protected by it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Protect a Directory with the help of a Password<\/h3>\n\n\n\n<p>1. Login to your cPanel account.<\/p>\n\n\n\n<p>2. Navigate to the&nbsp;<strong>Files<\/strong>&nbsp;section and click on&nbsp;<strong>Directory Privacy<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.hostvento.com\/kb\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg\" alt=\"\" class=\"wp-image-11182\"\/><\/figure>\n<\/div>\n\n\n<p>3. Click on the directory that you want to protect.<\/p>\n\n\n\n<p>4. You will be redirected to a page&nbsp;<strong>\u201cSet permissions for \u201c\/home\/idigitalcamp\/public_html\u201d<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.hostvento.com\/kb\/hosting-faqs\/wp-content\/uploads\/2021\/01\/set-permissions-new-min-1024x296.jpg\" alt=\"\" class=\"wp-image-11184\"\/><\/figure>\n<\/div>\n\n\n<p>5. Tick the option&nbsp;<strong>Password<\/strong>&nbsp;<strong>protect this directory<\/strong>&nbsp;as in the above screenshot.<\/p>\n\n\n\n<p>6. Under&nbsp;<strong>Security Settings<\/strong>&nbsp;type the name for the selected directory in the&nbsp;<strong>Enter a name for the protected directory<\/strong>&nbsp;field. Note that this is the label of that directory. It doesn\u2019t change the actual name of the directory.<\/p>\n\n\n\n<p>7. Next, click on the&nbsp;<strong>Save<\/strong>&nbsp;button.<\/p>\n\n\n\n<p>8. A confirmation page will get displayed. Here, click on&nbsp;<strong>Go Back<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.hostvento.com\/kb\/hosting-faqs\/wp-content\/uploads\/2021\/01\/success-message-min-1024x171.jpg\" alt=\"\" class=\"wp-image-11185\"\/><\/figure>\n<\/div>\n\n\n<p>9. Then you need to create a user that can access this directory. For this under&nbsp;<strong>Create User<\/strong>, fill in the&nbsp;<strong>Username<\/strong>,&nbsp;<strong>New Password<\/strong>, and&nbsp;<strong>Confirm Password<\/strong>&nbsp;fields. The&nbsp;<strong>Password Generator<\/strong>&nbsp;button will help you to generate a strong password.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.hostvento.com\/kb\/hosting-faqs\/wp-content\/uploads\/2021\/01\/create-user-min.jpg\" alt=\"\" class=\"wp-image-11186\"\/><\/figure>\n\n\n\n<p>10. Then click the&nbsp;<strong>Save<\/strong>&nbsp;button.<\/p>\n\n\n\n<p>11. Lastly, click on&nbsp;<strong>Go Back<\/strong>.<\/p>\n\n\n\n<p>12. To check if your directory has been password protected, go to your browser and browse the directory. If the browser asks you to log in, then your folder has been password protected. In this example, the public_html (the domain name, example.com) has been accessed in a browser. When anyone accesses it, a pop-up box will get displayed as below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.hostvento.com\/kb\/hosting-faqs\/wp-content\/uploads\/2021\/01\/popup-min-1024x174.jpg\" alt=\"\" class=\"wp-image-11187\"\/><\/figure>\n<\/div>\n\n\n<p><strong>Note:<\/strong>&nbsp;Enter the username and password created in the previous step to access the directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Getting a 404 Error When Browsing a URL With a Shared Server SSL<\/h3>\n\n\n\n<p>Suppose you are accessing a password-protected directory with a URL containing the use of a shared server SSL (https:\/\/securexxx.hostvento.com\/~\/) and getting a 404 error, it is because Apache is searching for a 401 page and displaying a 404 when it is not found.<\/p>\n\n\n\n<p>The solution to this error is to add a single line to the .htaccess file in the protected directory, so that Apache gets the 401 pages it is looking for (ErrorDocument 401 Authorization Required).<\/p>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<p>In the below code, ensure to replace yourusername with your actual cPanel username, and also ensure the example123 is replaced with your actual server number. You will get this information in your&nbsp;<strong>Welcome Email<\/strong>&nbsp;as well as on the left navigation menu in your cPanel.<\/p>\n\n\n\n<p><strong>Before Fix:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@example123 \/home\/yourusername\/www\/home]# more .htaccess.old\n\nAuthType Basic\nAuthName \"home\"\nAuthUserFile \"\/home\/yourusername\/.htpasswds\/public_html\/home\/passwd\"\nrequire valid-user<\/pre>\n\n\n\n<p><strong>After Fix:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@example123 \/home\/yourusername\/www\/home]# more .htaccess\n\nAuthType Basic\nAuthName \"home\"\nAuthUserFile \"\/home\/yourusername\/.htpasswds\/public_html\/home\/passwd\"\nrequire valid-user\nErrorDocument 401 \"Authorization Required\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Getting 500 Error After Login<\/h3>\n\n\n\n<p>Examine who owns the folder named &#8220;.htpasswds&#8221; (above &#8220;public_html&#8221;). Refresh your protected page after changing it from user.user to user.nobody and making sure the permissions are set to 750. There will be a fix for the mistake.<\/p>\n\n\n\n<p>This makes it simple to password-protect a directory.<\/p>\n\n\n\n<p><a href=\"http:\/\/hostvento.com\" target=\"_blank\" rel=\"noopener\"><strong>Get Shared Hosting <br><\/strong><\/a><a href=\"http:\/\/secure.hostvento.com\" target=\"_blank\" rel=\"noopener\"><strong>Get online hosting <br><\/strong><\/a><a href=\"http:\/\/hostvento.com\" target=\"_blank\" rel=\"noopener\"><strong>Get Free ssl certificate <\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With cPanel, directories may be password-protected. By doing this, every file inside the password-protected folders is secured. Note: Individual files cannot be protected by cPanel; only folders can. A protected directory is where you may find any file that needs to be secured. Furthermore, folders that are accessible locally or via FTP, SFTP, or Web [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":23377,"menu_order":1058,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-17856","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/comments?post=17856"}],"version-history":[{"count":2,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17856\/revisions"}],"predecessor-version":[{"id":20792,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17856\/revisions\/20792"}],"up":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/23377"}],"wp:attachment":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/media?parent=17856"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/doc_tag?post=17856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}