{"id":9673,"date":"2025-10-02T05:17:36","date_gmt":"2025-10-02T05:17:36","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=9673"},"modified":"2025-10-02T05:19:27","modified_gmt":"2025-10-02T05:19:27","slug":"password-protect-directory-apache","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/","title":{"rendered":"How to Password Protect Directory in Apache"},"content":{"rendered":"\n<p>When we setup a website or a blog, there will often be some pages that you do not want unauthorized visitors to access. Although it is possible to code the password authentication for web pages, did you know that you can directly use Apache web server for user authentication? If you just need simple password authentication and do not have software developers to code it for you, then you can utilize this feature in Apache server. In this article, we will learn how to password protect directory in Apache web server.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#Why_Password_Protect_Directory_in_Apache\" >Why Password Protect Directory in Apache<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#How_to_Password_Protect_Directory_in_Apache\" >How to Password Protect Directory in Apache<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#1_Install_Required_Apache_Utilities\" >1. Install Required Apache Utilities<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#2_Create_Password_File\" >2. Create Password File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#3_Configure_Password_Authentication\" >3. Configure Password Authentication<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#Using_Virtual_Host_Configuration_File\" >Using Virtual Host Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#Using_htaccess_File\" >Using .htaccess File<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#4_Restart_Apache_Server\" >4. Restart Apache Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#5_Test_Password_Authentication\" >5. Test Password Authentication<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Password_Protect_Directory_in_Apache\"><\/span>Why Password Protect Directory in Apache<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Every website or blog has web pages with sensitive content such as admin pages, user details, etc. Most site administrators need to protect these web pages with sensitive information from unauthorized users. Using Apache&#8217;s password authentication is a very simple, quick and powerful way to add user authorization to your website, without any coding.<\/p>\n\n\n\n<p>Another useful benefit is that it allows you to enable user authentication for specific pages, directories, or entire site, in a matter of minutes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Password_Protect_Directory_in_Apache\"><\/span>How to Password Protect Directory in Apache<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to password protect directory in Apache server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Install_Required_Apache_Utilities\"><\/span>1. Install Required Apache Utilities<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First of all, we need to create a file that stores username and passwords. For that purpose, we use htpasswd utility. It allows us to add username-password combinations that are allowed to access password protected content. htpasswd is available in apache2-utils package. You can install it with the following commands. Here we update local packages and install htpasswd.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get update<br>sudo apt-get install apache2-utils<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Create_Password_File\"><\/span>2. Create Password File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Once htpasswd is installed, we will use it to create new username-password combinations. htpasswd requires the location of file that will store this information. Here is the command to add username-password combination to this file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo htpasswd -c &lt;file_location&gt; &lt;username&gt;<\/pre>\n\n\n\n<p>Here is an example to demonstrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo htpasswd -c \/home\/ubuntu\/userpass test_user<\/pre>\n\n\n\n<p>In the above command, we supply file location as <em>\/home\/ubuntu\/userpass<\/em> and username as test_user. If this file does not exist, it will be created. Also, since you are entering username for the first time, you need to add -c option. For subsequent users, you can omit it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo htpasswd -c \/home\/ubuntu\/userpass test_user2<\/pre>\n\n\n\n<p>Once you enter the above command, you will be prompted for password. Enter the password to save the username-password combination. These passwords are encrypted before being stored in the file. You can view its contents using cat or similar command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat \/home\/ubuntu\/userpass<br><br>Output<br>test_user:$jan1$efgsIfXG$tmCvCfb34fpPFwKGVsuYz.<br>test_user2:$jan1$p1gjjeAf$efrhneUwr.MhAE2kKGYHK.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Configure_Password_Authentication\"><\/span>3. Configure Password Authentication<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Next, we need to configure Apache to use this file to check if the requested URL is a protected on, and also to cross check user credentials against it for authorization. There are 3 ways to do this.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Using virtual host file<\/li>\n\n\n\n<li>Using .htaccess file<\/li>\n<\/ol>\n\n\n\n<p>In the first option, we modify the virtual host file to add location of htpasswd file. It is read by Apache whenever server is started or restarted. It is much faster than using .htaccess to add password protection because the config files are read only once in a while when server is started or reloaded. Also, since it is a single file, Apache server does not need to look into multiple places to authenticate users.<\/p>\n\n\n\n<p>If you are using .htaccess file, then Apache will need to re-read this file at every request, which can slow down performance. However, in most deployments, users do not have access to virtual host config file but only to .htaccess file. So this is a more practical solution.<\/p>\n\n\n\n<p>Let us look at these methods below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_Virtual_Host_Configuration_File\"><\/span>Using Virtual Host Configuration File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this approach, we first open the default virtual configuration file 000-default.conf in a text editor.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/apache2\/sites-enabled\/000-default.conf<\/pre>\n\n\n\n<p>Look for the following code block. If it is commented, remove the # sign at the beginning of the lines.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;VirtualHost *:80><br>    ServerAdmin webmaster@localhost<br>    DocumentRoot \/var\/www\/html<br>    ErrorLog ${APACHE_LOG_DIR}\/error.log<br>    CustomLog ${APACHE_LOG_DIR}\/access.log combined<br>&lt;\/VirtualHost><\/pre>\n\n\n\n<p>In this case, authentication is done for specific directories. So if you want to password protect the entire root directory then add the following lines to it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"><br>&lt;\/Directory><\/pre>\n\n\n\n<p>Within this block, we need to specify the AuthType as Basic, since we need basic authentication. Next, we need to specify AuthName as any realm name you want. The AuthUserFile directive should point to the htpasswd file location that we created earlier. Lastly, we specify the Require directive to be a valid-user which means that anyone with a valid username and password combination can be authorized. So add the following 4 lines within the above Directory block.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"><br>        AuthType Basic<br>        AuthName \"Restricted Content\"<br>        AuthUserFile \/home\/ubuntu\/userpass<br>        Require valid-user<br>    &lt;\/Directory><\/pre>\n\n\n\n<p>Save and close the file. Proceed to the next step to restart Apache server and apply changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_htaccess_File\"><\/span>Using .htaccess File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you do not have access to .htaccess file, then you can update .htaccess file for this purpose. Here we will first enable .htaccess file and then modify it. If you have already enabled it on your server, you can proceed to modify it, as shown later in this step.<\/p>\n\n\n\n<p>First, open Apache main configuration file in text editor.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/apache2\/apache2.conf<\/pre>\n\n\n\n<p>Look for the following code block that points to the root directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">. . .<br><br>&lt;Directory \/var\/www\/><br>    Options Indexes FollowSymLinks<br>    AllowOverride None<br>    Require all granted<br>&lt;\/Directory><br><br>. . .<\/pre>\n\n\n\n<p>In the above code, change AllowOverride from None to All.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">. . .<br><br>&lt;Directory \/var\/www\/><br>    Options Indexes FollowSymLinks<br>    AllowOverride All<br>    Require all granted<br>&lt;\/Directory><br><br>. . .<\/pre>\n\n\n\n<p>Save and close the file to enable .htaccess.<\/p>\n\n\n\n<p>Next, add a .htaccess file to the directory that you want to password protect. Here we create a file in root directory, since we password protect its contents.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/var\/www\/html\/.htaccess<\/pre>\n\n\n\n<p>In this file, we mention the 4 directives described earlier, for authentication. We specify AuthType as Basic. Next, we mention AuthName directive as realm name as per your requirement. Then we mention AuthUserFile as the location to htpasswd file. Lastly, we mention the Require directive as valid-user directive, meaning anyone with valid username and password will be able to get access.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">AuthType Basic<br>AuthName \"Restricted Content\"<br>AuthUserFile \/etc\/apache2\/.htpasswd<br>Require valid-user<\/pre>\n\n\n\n<p>Save and close the file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Restart_Apache_Server\"><\/span>4. Restart Apache Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Restart Apache server to apply changes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo service apache2 restart<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Test_Password_Authentication\"><\/span>5. Test Password Authentication<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To test the above configuration, open web browser and try to access any of the password protected URLs. You will see the following prompt that asks you to enter username and password.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"273\" src=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password_prompt.png?resize=350%2C273&#038;ssl=1\" alt=\"\" class=\"wp-image-9685\"\/><\/figure>\n<\/div>\n\n\n<p>If you enter the correct username and password, you will be granted access to the requested URL. Else, you will see the following message.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"715\" height=\"136\" src=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/unauthorized_error-1.png?resize=715%2C136&#038;ssl=1\" alt=\"\" class=\"wp-image-9684\"\/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt a couple of simple ways to easily add basic password authentication in Apache server. It allows you to protect one or more pages on your website\/blog, without any coding. It is easy to manage for system administrators. You can customize it as per your requirement.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/speed-apache-web-server\/\">How to Speed Up Apache Web Server<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/apache-deny-access-to-url-files-directory\/\">Apache Deny Access to URL, Files &amp; Directory<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-enable-server-side-includes-ssi-in-apache\/\">How to Enable Server Side Includes in Apache<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.<\/p>\n","protected":false},"author":1,"featured_media":9698,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[612],"class_list":["post-9673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","tag-password-protection"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Password Protect Directory in Apache - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Password Protect Directory in Apache - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-02T05:17:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-02T05:19:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"303\" \/>\n\t<meta property=\"og:image:height\" content=\"202\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Password Protect Directory in Apache\",\"datePublished\":\"2025-10-02T05:17:36+00:00\",\"dateModified\":\"2025-10-02T05:19:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/\"},\"wordCount\":1067,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1\",\"keywords\":[\"password protection\"],\"articleSection\":[\"Apache\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/\",\"name\":\"How to Password Protect Directory in Apache - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1\",\"datePublished\":\"2025-10-02T05:17:36+00:00\",\"dateModified\":\"2025-10-02T05:19:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1\",\"width\":303,\"height\":202,\"caption\":\"password protect directory in apache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/password-protect-directory-apache\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Password Protect Directory in Apache\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Password Protect Directory in Apache - Ubiq BI","description":"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.","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:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/","og_locale":"en_US","og_type":"article","og_title":"How to Password Protect Directory in Apache - Ubiq BI","og_description":"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.","og_url":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-10-02T05:17:36+00:00","article_modified_time":"2025-10-02T05:19:27+00:00","og_image":[{"width":303,"height":202,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Password Protect Directory in Apache","datePublished":"2025-10-02T05:17:36+00:00","dateModified":"2025-10-02T05:19:27+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/"},"wordCount":1067,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1","keywords":["password protection"],"articleSection":["Apache"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/","url":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/","name":"How to Password Protect Directory in Apache - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1","datePublished":"2025-10-02T05:17:36+00:00","dateModified":"2025-10-02T05:19:27+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to enable password protection in Apache server. Here are the steps to password protect directory in Apache server.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1","width":303,"height":202,"caption":"password protect directory in apache"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/password-protect-directory-apache\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Password Protect Directory in Apache"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/10\/password-protect-directory-apache.jpg?fit=303%2C202&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2w1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/9673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=9673"}],"version-history":[{"count":20,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/9673\/revisions"}],"predecessor-version":[{"id":9696,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/9673\/revisions\/9696"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/9698"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=9673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=9673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=9673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}