{"id":9304,"date":"2021-02-04T09:33:41","date_gmt":"2021-02-04T09:33:41","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=9304"},"modified":"2024-04-23T14:39:33","modified_gmt":"2024-04-23T13:39:33","slug":"password-protect-one-file","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/","title":{"rendered":"How to Password Protect One File from cPanel?"},"content":{"rendered":"<p>For password protecting an individual file, follow the below steps:<\/p>\n<p>1. Login to your cPanel account.<\/p>\n<p>2. Go to <strong>Files<\/strong> and click on <strong>File Manager<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11470\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg\" alt=\"\" width=\"1024\" height=\"224\" \/><\/p>\n<p>3. In your root directory, create a file with the name<strong> .htpasswd<\/strong>. This won\u2019t be accessible to visitors.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11471\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/htpasswd-file-created-min.jpg\" alt=\"\" width=\"629\" height=\"661\" \/><\/p>\n<ul>\n<li>Here\u2019s an example of the root directory pathway for <strong>shared accounts<\/strong>: <strong>\/home#\/cpanelusername\/.htpasswd<\/strong><\/li>\n<li>Here\u2019s an example of the root directory pathway for <strong>reseller, VPS and dedicated server accounts<\/strong>: <strong>\/home\/cpanelusername\/.htpasswd<\/strong><\/li>\n<li>In this tutorial, the root directory pathway will be:<strong> \/home\/idigitalcamp\/.htpasswd<\/strong><\/li>\n<\/ul>\n<p>4. Create an encrypted password with the help of either using the command line program htpasswd or an <a href=\"https:\/\/hostingcanada.org\/htpasswd-generator\/\" target=\"_blank\" rel=\"nofollow noopener\"><strong>htpasswd generator<\/strong><\/a>. The number of individual files you wish to protect won\u2019t matter; all those can share a common .htpasswd file.<\/p>\n<p>5. Here we will create an encrypted password with an htpasswd generator. When you go to the htpasswd generator, you will be asked to enter the username and password. Then click on the <strong>Create<\/strong> <strong>.htpasswdfile<\/strong> button as below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11472\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/password-generator-min.jpg\" alt=\"\" width=\"1017\" height=\"485\" \/><\/p>\n<p>6. You will get the encrypted password for the username as <strong>\u201cidigitalcamp:{SHA}URw6KZPcsyJ6d7RjdXWhKEpCI0s=\u201d<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11473\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/password-min-1024x93.jpg\" alt=\"\" width=\"1024\" height=\"93\" \/><\/p>\n<p>7. Then go back to the root directory and right click on the <strong>.htpasswd<\/strong> file and select the <strong>Edit<\/strong> option.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11474\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/htpasswd-edit-min.jpg\" alt=\"\" width=\"361\" height=\"297\" \/><\/p>\n<p>8. The edit confirmation popup appears, click on the <strong>Edit<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11475\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/edit-min-1.jpg\" alt=\"\" width=\"502\" height=\"348\" \/><\/p>\n<p>9. Insert the generated <strong>encrypted password information <\/strong>above into the <strong>.htpasswd<\/strong> file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11476\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/save-changes-min-1024x103.jpg\" alt=\"\" width=\"1024\" height=\"103\" \/><\/p>\n<p>10. Click on the <strong>Save Changes<\/strong> and <strong>Close<\/strong> button to close the window.<\/p>\n<p>11. Go to the directory where the file(s) that you want to password protect is present. Here we are protecting the <strong>test.php<\/strong> file present in the <strong>public_html -&gt; test<\/strong> folder. For this, you will need to paste the below code in .htaccess file of the folder where the <strong>test.php<\/strong> file exists. If an .htaccess file isn\u2019t there in the directory, you will need to create it.<\/p>\n<p>12. Right click on the<strong> .htaccess<\/strong> file and click on <strong>Edit<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11477\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/htaccess-file-min-1024x432.jpg\" alt=\"\" width=\"1024\" height=\"432\" \/><\/p>\n<p>13. Again click on <strong>Edit<\/strong> for confirmation to edit and then paste the below code:<\/p>\n<pre class=\"lang:default decode:true\">&lt;FilesMatch \"examplefile.extension\"&gt;\nAuthName \"Member Only\"\nAuthType Basic\nAuthUserFile \/home\/cpanelusername\/.htpasswd\nrequire valid-user\n&lt;\/FilesMatch&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11478\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/code-htaccess-min-1024x156.jpg\" alt=\"\" width=\"1024\" height=\"156\" \/><\/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> Replace <strong>examplefile.extension<\/strong> with your file&#8217;s actual name and replace <strong>cpanelusername<\/strong> with your actual cPanel username.<\/p>\n<\/div>\n<\/div>\n<p>14. Then click on the <strong>Save Changes<\/strong> button and again click on the <strong>Close<\/strong> button.<\/p>\n<p>15. With this, the specified file will be protected with password and other files in the folder will remain unprotected.<\/p>\n<p>16. To check if the file is password protected, we will browse here:<strong> https:\/\/idigitalcamp.com\/test\/test.php. <\/strong>Here replace <strong>idigitalcamp.com<\/strong> with your actual domain name and<strong> test.php<\/strong> with your file that you have password protected during the process.<strong><br \/>\n<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11479\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/browse-file-min-1024x175.jpg\" alt=\"\" width=\"1024\" height=\"175\" \/><\/p>\n<p>17. Enter the username and password and click on <strong>OK\/Sign-in<\/strong>. Note that you use the original password used in <strong>htpasswd generator<\/strong> and not the encrypted password.<\/p>\n<p>18. You will see the content in that file as below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-11480\" src=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/content-file-min-1024x142.jpg\" alt=\"\" width=\"1024\" height=\"142\" \/><\/p>\n<p>In this way, you can password protect one file from cPanel.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For password protecting an individual file, follow the below steps: 1. Login to your cPanel account. 2. Go to Files and click on File Manager. 3. In your root directory, create a file with the name .htpasswd. This won\u2019t be accessible to visitors. Here\u2019s an example of the root directory pathway for shared accounts: \/home#\/cpanelusername\/.htpasswd [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1797,1842,1799,1798],"class_list":["post-9304","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-cpanel-faq","tag-password-protect-one-file","tag-password-protect-one-file-from-cpanel","tag-password-protection","tag-protect-a-file-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 Password Protect One File from cPanel?<\/title>\n<meta name=\"description\" content=\"The article reveals steps to password protect one file from cPanel.\" \/>\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\/password-protect-one-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Password Protect One File from cPanel?\" \/>\n<meta property=\"og:description\" content=\"The article reveals steps to password protect one file from cPanel.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-04T09:33:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-23T13:39:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.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=\"5 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\/password-protect-one-file\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/\",\"name\":\"How to Password Protect One File from cPanel?\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg\",\"datePublished\":\"2021-02-04T09:33:41+00:00\",\"dateModified\":\"2024-04-23T13:39:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"The article reveals steps to password protect one file from cPanel.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg\",\"contentUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Password Protect One File from cPanel?\"}]},{\"@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 Password Protect One File from cPanel?","description":"The article reveals steps to password protect one file from cPanel.","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\/password-protect-one-file\/","og_locale":"en_GB","og_type":"article","og_title":"How to Password Protect One File from cPanel?","og_description":"The article reveals steps to password protect one file from cPanel.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2021-02-04T09:33:41+00:00","article_modified_time":"2024-04-23T13:39:33+00:00","og_image":[{"url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg","type":"","width":"","height":""}],"author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Estimated reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/","name":"How to Password Protect One File from cPanel?","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg","datePublished":"2021-02-04T09:33:41+00:00","dateModified":"2024-04-23T13:39:33+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"The article reveals steps to password protect one file from cPanel.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#primaryimage","url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg","contentUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2021\/02\/file-manager-min-1-1024x224.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/password-protect-one-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Password Protect One File from cPanel?"}]},{"@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":435,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9304","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=9304"}],"version-history":[{"count":9,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9304\/revisions"}],"predecessor-version":[{"id":15518,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9304\/revisions\/15518"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=9304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=9304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=9304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}