{"id":1281,"date":"2011-07-15T20:30:33","date_gmt":"2011-07-15T12:30:33","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1281"},"modified":"2023-04-28T09:50:17","modified_gmt":"2023-04-28T09:50:17","slug":"how-to-disable-directory-browsing-on-website-or-blog","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-disable-directory-browsing-on-website-or-blog\/","title":{"rendered":"How to Disable Directory Browsing on Website or Blog"},"content":{"rendered":"<p>Directory browsing allows users to view the contents of a directory on your website or blog. While this feature can be helpful in certain situations, it can also be a security risk as it exposes the files and directories on your server to potential attackers.<\/p>\n<p>In this guide, we will show you how to disable directory browsing on your website or blog using httpd.conf and .htaccess files.<\/p>\n<h2>Step 1: Locate the httpd.conf File<\/h2>\n<p>The httpd.conf file is the main configuration file for the Apache web server. It is usually located in the \/etc\/httpd\/ or \/etc\/apache2\/ directory, depending on your server setup. You will need root access to edit this file.<\/p>\n<h2>Step 2: Edit the httpd.conf File<\/h2>\n<p>Open the httpd.conf file in a text editor such as nano or vi. Locate the following line:<\/p>\n<pre>Options Indexes FollowSymLinks<\/pre>\n<p>Remove the word &#8220;Indexes&#8221; from the line so that it reads:<\/p>\n<pre>Options FollowSymLinks<\/pre>\n<p>Save the changes and exit the editor.<\/p>\n<h2>Step 3: Restart the Apache Web Server<\/h2>\n<p>Restart the Apache web server to apply the changes. Run the following command in your terminal:<\/p>\n<pre>sudo service httpd restart<\/pre>\n<h2>Step 4: Create or Edit the .htaccess File<\/h2>\n<p>If you do not have access to the httpd.conf file, or if you want to disable directory browsing for a specific directory, you can use the .htaccess file. Create a new .htaccess file in the directory you want to protect, or edit the existing one if it already exists.<\/p>\n<p>Add the following line to the .htaccess file:<\/p>\n<pre>Options -Indexes<\/pre>\n<p>This line disables directory browsing for the directory and its subdirectories.<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo service httpd restart<\/span> &#8211; Restart the Apache web server<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this guide, we have shown you how to disable directory browsing on your website or blog using httpd.conf and .htaccess files. By following these steps, you can protect your server from potential security risks by preventing users from viewing the contents of your directories. We recommend that you always keep your web server and website security up to date to prevent unauthorized access. If you have any comments or suggestions for improvements, please feel free to share them below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Directory browsing allows users to view the contents of a directory on your website or blog. While this feature can be helpful in certain situations, it can also be a&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[996],"tags":[1199,1536],"class_list":["post-1281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-apache","tag-linux"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1281"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1281\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}