{"id":9050,"date":"2021-01-14T09:15:15","date_gmt":"2021-01-14T09:15:15","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=9050"},"modified":"2024-04-24T06:49:15","modified_gmt":"2024-04-24T05:49:15","slug":"protect-directory-with-password","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/","title":{"rendered":"How to Protect a Directory with a Password?"},"content":{"rendered":"<p>Directories can be password protected via cPanel. This secures all the files within the password-protected folders.<\/p>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info kb-wisdom-wrapr-blue\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p><strong>Note:<\/strong> The cPanel can only protect directories and not individual files. Any file that needs to be protected can be located in a protected directory. Moreover, it does not protect the directories that are accessible locally or through FTP, SFTP, or Web Disk.<\/p>\n<\/div>\n<\/div>\n<h3>Steps to Protect a Directory with the help of a Password<\/h3>\n<p>1. Login to your cPanel account.<\/p>\n<p>2. Navigate to the <strong>Files<\/strong> section and click on <strong>Directory Privacy<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11182\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg\" alt=\"\" width=\"1024\" height=\"215\" \/><\/p>\n<p>3. Click on the directory that you want to protect.<\/p>\n<p>4. You will be redirected to a page <strong>\u201cSet permissions for \u201c\/home\/idigitalcamp\/public_html\u201d<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11184\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/set-permissions-new-min-1024x296.jpg\" alt=\"\" width=\"1024\" height=\"296\" \/><\/p>\n<p>5. Tick the option <strong>Password protect this directory<\/strong> as in the above screenshot.<\/p>\n<p>6. Under <strong>Security Settings<\/strong> type the name for the selected directory in the <strong>Enter a name for the protected directory<\/strong> field. Note that this is the label of that directory. It doesn\u2019t change the actual name of the directory.<\/p>\n<p>7. Next, click on the <strong>Save<\/strong> button.<\/p>\n<p>8. A confirmation page will get displayed. Here, click on <strong>Go Back<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11185\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/success-message-min-1024x171.jpg\" alt=\"\" width=\"1024\" height=\"171\" \/><\/p>\n<p>9. Then you need to create a user that can access this directory. For this under <strong>Create User<\/strong>, fill in the <strong>Username<\/strong>, <strong>New Password<\/strong>, and <strong>Confirm Password<\/strong> fields. The <strong>Password Generator<\/strong> button will help you to generate a strong password.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11186\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/create-user-min.jpg\" alt=\"\" width=\"950\" height=\"383\" \/><\/p>\n<p>10. Then click the <strong>Save<\/strong> button.<\/p>\n<p>11. Lastly, click on <strong>Go Back<\/strong>.<\/p>\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<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11187\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/popup-min-1024x174.jpg\" alt=\"\" width=\"1024\" height=\"174\" \/><\/p>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info kb-wisdom-wrapr-blue\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p><strong>Note:<\/strong> Enter the username and password created in the previous step to access the directory.<\/p>\n<\/div>\n<\/div>\n<h3>Getting a 404 Error When Browsing a URL With a Shared Server SSL<\/h3>\n<p>Suppose you are accessing a password-protected directory with a URL containing the use of a shared server SSL (https:\/\/securexxx.milesweb.co.uk\/~\/) 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<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<p><strong>Example<\/strong><\/p>\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 <strong>Welcome Email<\/strong> as well as on the left navigation menu in your cPanel.<\/p>\n<p><strong>Before Fix:<\/strong><\/p>\n<pre class=\"lang:default decode:true \">[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<p><strong>After Fix:<\/strong><\/p>\n<pre class=\"lang:default decode:true \">[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<h3>Getting 500 Error After Login<\/h3>\n<p>Check the ownership on the .htpasswds folder (above public_html). Change it from <strong>user.user<\/strong> to <strong>user.nobody<\/strong> and check if the permissions are set to<strong> 750<\/strong> and then refresh your protected page. The error will be resolved.<\/p>\n<p>In this way, you can easily protect a directory with a password.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Directories can be password protected via cPanel. This secures all the files within the password-protected folders. Note: The cPanel can only protect directories and not individual files. Any file that needs to be protected can be located in a protected directory. Moreover, it does not protect the directories that are accessible locally or through FTP, [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[1742,1743,1741],"class_list":["post-9050","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-password-protect-directory","tag-password-protect-directory-cpanel","tag-protect-directory-with-password"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Protect a Directory with a Password?<\/title>\n<meta name=\"description\" content=\"The article reveals steps to protect a directory with a password.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Protect a Directory with a Password?\" \/>\n<meta property=\"og:description\" content=\"The article reveals steps to protect a directory with a password.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-14T09:15:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-24T05:49:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg\" \/>\n<meta name=\"author\" content=\"Pallavi Godse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Godse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/\",\"name\":\"How to Protect a Directory with a Password?\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg\",\"datePublished\":\"2021-01-14T09:15:15+00:00\",\"dateModified\":\"2024-04-24T05:49:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"The article reveals steps to protect a directory with a password.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2019\/10\/whm_virus_scanner.png\",\"contentUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2019\/10\/whm_virus_scanner.png\",\"width\":1261,\"height\":676},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Protect a Directory with a Password?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\",\"name\":\"Pallavi Godse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"caption\":\"Pallavi Godse\"},\"description\":\"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Protect a Directory with a Password?","description":"The article reveals steps to protect a directory with a password.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/","og_locale":"en_GB","og_type":"article","og_title":"How to Protect a Directory with a Password?","og_description":"The article reveals steps to protect a directory with a password.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2021-01-14T09:15:15+00:00","article_modified_time":"2024-04-24T05:49:15+00:00","og_image":[{"url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg","type":"","width":"","height":""}],"author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/","name":"How to Protect a Directory with a Password?","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/01\/directory-privacy-min-1024x215.jpg","datePublished":"2021-01-14T09:15:15+00:00","dateModified":"2024-04-24T05:49:15+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"The article reveals steps to protect a directory with a password.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#primaryimage","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2019\/10\/whm_virus_scanner.png","contentUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2019\/10\/whm_virus_scanner.png","width":1261,"height":676},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/protect-directory-with-password\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Protect a Directory with a Password?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945","name":"Pallavi Godse","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","caption":"Pallavi Godse"},"description":"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/"}]}},"views":367,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=9050"}],"version-history":[{"count":4,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9050\/revisions"}],"predecessor-version":[{"id":15542,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9050\/revisions\/15542"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=9050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=9050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=9050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}