{"id":1375,"date":"2026-10-19T09:59:05","date_gmt":"2026-10-19T09:59:05","guid":{"rendered":"https:\/\/www.freethought.uk\/help\/?p=1375"},"modified":"2026-10-19T09:59:07","modified_gmt":"2026-10-19T09:59:07","slug":"how-to-disable-directory-indexing-and-prevent-file-browsing","status":"publish","type":"post","link":"https:\/\/www.freethought.uk\/help\/how-to-disable-directory-indexing-and-prevent-file-browsing\/","title":{"rendered":"How to Disable Directory Indexing and Prevent File Browsing"},"content":{"rendered":"\n<p>When a website folder lacks an index file (such as <code>index.php<\/code> or <code>index.html<\/code>), web servers often display a full list of all files in that directory. Known as directory indexing or directory browsing, this allows visitors to browse raw uploads, plugin files, or site assets, posing privacy and security risks.<\/p>\n\n\n\n<p>Disabling directory indexing ensures visitors see a <strong>403 Forbidden<\/strong> page instead of a list of your files. You can configure this using cPanel, Plesk, or your <code>.htaccess<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"method-1-using-htaccess-recommended\">Method 1: Using <code>.htaccess<\/code> (Recommended)<\/h3>\n\n\n\n<p>Editing your <code>.htaccess<\/code> file applies rules directly to the web server and works on both cPanel and Linux-based web hosting environments.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Log into your hosting control panel and open <strong>File Manager<\/strong>.<\/li>\n\n\n\n<li>Navigate to your website&#8217;s root directory (typically <code>public_html<\/code>).<\/li>\n\n\n\n<li>Ensure hidden files are visible (in cPanel File Manager, click <strong>Settings<\/strong> at the top right and check <strong>Show Hidden Files (dotfiles)<\/strong>).<\/li>\n\n\n\n<li>Edit the <code>.htaccess<\/code> file (or create one if it does not exist).<\/li>\n\n\n\n<li>Add the following line at the top of the file:<br><code>Options -Indexes<\/code><\/li>\n\n\n\n<li>Click <strong>Save Changes<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"method-2-using-the-indexes-feature-in-cpanel\">Method 2: Using the &#8220;Indexes&#8221; Feature in cPanel<\/h3>\n\n\n\n<p>If you prefer a graphical menu without editing code directly, cPanel offers a built-in Index Manager tool:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>Step<\/strong><\/td><td><strong>Action<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>1. Open Indexes<\/strong><\/td><td>Log into cPanel, scroll to the <strong>Advanced<\/strong> section, and click <strong>Indexes<\/strong>.<\/td><\/tr><tr><td><strong>2. Select Directory<\/strong><\/td><td>Click through the file tree to locate the directory you want to secure.<\/td><\/tr><tr><td><strong>3. Edit Settings<\/strong><\/td><td>Click <strong>Edit<\/strong> next to the target folder.<\/td><\/tr><tr><td><strong>4. Disable Indexing<\/strong><\/td><td>Select <strong>No Indexing<\/strong> (or <em>Inherit<\/em> if the parent folder is already set to No Indexing).<\/td><\/tr><tr><td><strong>5. Save<\/strong><\/td><td>Click <strong>Save<\/strong>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"method-3-disabling-directory-browsing-in-plesk\">Method 3: Disabling Directory Browsing in Plesk<\/h3>\n\n\n\n<p>You can disable file listings in Plesk either through domain server settings or directly via the File Manager.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"option-a-via-apache-nginx-settings\">Option A: Via Apache &amp; nginx Settings<\/h4>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Log into Plesk and select your domain.<\/li>\n\n\n\n<li>Go to the <strong>Hosting &amp; DNS<\/strong> tab and click <strong>Apache &amp; nginx Settings<\/strong>.<\/li>\n\n\n\n<li>Scroll down to <strong>Additional Apache directives<\/strong>.<\/li>\n\n\n\n<li>In the text boxes for both <strong>Additional directives for HTTP<\/strong> and <strong>Additional directives for HTTPS<\/strong>, add:<br><code>Options -Indexes<\/code><\/li>\n\n\n\n<li>Click <strong>OK<\/strong> to save changes.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"option-b-via-plesk-file-manager\">Option B: Via Plesk File Manager<\/h4>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Go to <strong>Files &amp; Databases<\/strong> &gt; <strong>Files<\/strong> and open your <code>httpdocs<\/code> or <code>public_html<\/code> folder.<\/li>\n\n\n\n<li>Edit your <code>.htaccess<\/code> file (create one if it does not exist).<\/li>\n\n\n\n<li>Add <code>Options -Indexes<\/code> to the top of the file and click <strong>Save<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"testing-your-changes\">Testing Your Changes<\/h3>\n\n\n\n<p>To confirm directory indexing is successfully disabled, open a browser window and visit a subfolder on your website that does not contain an index file (for example, <code>https:\/\/yourdomain.co.uk\/wp-content\/uploads\/<\/code>).<\/p>\n\n\n\n<p>If configured correctly, the browser should display a <strong>403 Forbidden<\/strong> error page rather than a list of files.<\/p>\n\n\n\n<p>If you&#8217;re still experiencing issues after following the steps above, please contact our support team and we&#8217;ll be happy to help.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When a website folder lacks an index file (such as index.php or index.html), web servers often display a full list of all files in that directory. Known as directory indexing or directory browsing, this allows visitors to browse raw uploads, plugin files, or site assets, posing privacy and security risks.&hellip;<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,3,25,16],"tags":[],"class_list":["post-1375","post","type-post","status-publish","format-standard","hentry","category-advanced-techniques","category-cpanel","category-plesk","category-security"],"_links":{"self":[{"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/posts\/1375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/comments?post=1375"}],"version-history":[{"count":1,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/posts\/1375\/revisions"}],"predecessor-version":[{"id":1376,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/posts\/1375\/revisions\/1376"}],"wp:attachment":[{"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/media?parent=1375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/categories?post=1375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freethought.uk\/help\/wp-json\/wp\/v2\/tags?post=1375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}