{"id":14232,"date":"2025-02-12T18:34:50","date_gmt":"2025-02-12T13:04:50","guid":{"rendered":"https:\/\/www.skynats.com\/?p=14232"},"modified":"2025-02-12T18:34:53","modified_gmt":"2025-02-12T13:04:53","slug":"how-to-disable-directory-listing-in-cpanel-with-apache","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/","title":{"rendered":"How to Disable Directory Listing in cPanel with Apache"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-introduction\" style=\"font-size:18px\">Introduction<\/h2>\n\n\n\n<p>When managing a website, prioritizing security is crucial. One common vulnerability is Apache&#8217;s default setting that enables directory listing. This means that if an index file (such as index.html or index.php) is absent, visitors can access a complete list of files and folders within that directory. This unintentional exposure of sensitive files can put your site at risk. Learning How to Disable Directory Listing in <a href=\"https:\/\/cpanel.net\/\">cPanel<\/a> is an essential step to protect your website from potential threats.<\/p>\n\n\n\n<p>To prevent this security risk, it&#8217;s essential to disable directory listing on your cPanel server. In this guide, we\u2019ll walk you through the three best methods to secure your website by turning off directory listing effectively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">Method 1: Using .htaccess (Per Website Basis)<\/h2>\n\n\n\n<p>1. Log in to cPanel.<\/p>\n\n\n\n<p>2. Navigate to File Manager and go to your website&#8217;s root directory (generally public_html).<\/p>\n\n\n\n<p>3. Edit or create a .htaccess file:<\/p>\n\n\n\n<p>Right-click on .htaccess and select Edit.<\/p>\n\n\n\n<p>If it doesn\u2019t exist, create one.<\/p>\n\n\n\n<p>4. Add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Options -Indexes<\/code><\/pre>\n\n\n\n<p>5. Save changes and close the editor.<\/p>\n\n\n\n<p>Verify: Visit a directory without an index file (e.g., http:\/\/yourdomain.com\/folder\/). You should see a 403 Forbidden error instead of a directory listing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:18px\">Method 2: Using WHM (Global Settings for All Domains)<\/h2>\n\n\n\n<p>If you need to apply server-wide changes without modifying individual domain settings, WHM offers a centralized way to configure all domains on the server. Here\u2019s how to do it:<\/p>\n\n\n\n<p>1. Log in to WHM as the root user.<\/p>\n\n\n\n<p>2. Go to Home \u2192 Service Configuration \u2192 Apache Configuration \u2192 Global Configuration.<\/p>\n\n\n\n<p>3. Scroll to the &#8220;Directory Options&#8221; section.<\/p>\n\n\n\n<p>4. Uncheck the &#8220;Indexes&#8221; option if it&#8217;s enabled.<\/p>\n\n\n\n<p>5. Save and Rebuild Apache Configuration when prompted.<\/p>\n\n\n\n<p>6. Restart Apache:<\/p>\n\n\n\n<p>Navigate to Home \u2192 Restart Services \u2192 HTTP Server (Apache).<\/p>\n\n\n\n<p>Click Yes to confirm.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:18px\">Method 3: Using SSH (For Root Access)<\/h3>\n\n\n\n<p>1. Access the server via SSH as the root user.<\/p>\n\n\n\n<p>2. Edit the Apache configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#vim \/etc\/apache2\/conf\/httpd.conf<\/code><\/pre>\n\n\n\n<p>3. Find the Directory Block and modify it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \"\/home\">\n    Options -Indexes\n    AllowOverride All\n&lt;\/Directory><\/code><\/pre>\n\n\n\n<p>4. Save the file and exit the editor.<\/p>\n\n\n\n<p>5. Restart Apache to apply changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#systemctl restart httpd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:18px\">Conclusion<\/h3>\n\n\n\n<p>Disabling directory listing is a simple yet effective way to enhance your website\u2019s security. Whether you prefer using cPanel, WHM, or SSH, the above methods will help you secure your directories from unauthorized browsing.<\/p>\n\n\n\n<p>For maximum security, consider combining these steps with other server hardening techniques.<\/p>\n\n\n\n<p>If you need further assistance or have any questions about How to Disable Directory Listing in cPanel with Apache, feel free to contact our <a href=\"https:\/\/www.skynats.com\/blog\/\">support team<\/a> for expert guidance and help securing your website. We&#8217;re here to assist you every step of the way!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction When managing a website, prioritizing security is crucial. One common vulnerability is Apache&#8217;s default setting that enables directory listing. This means that if an index file (such as index.html or index.php) is absent, visitors can access a complete list of files and folders within that directory. This unintentional exposure of sensitive files can put [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,964],"class_list":["post-14232","post","type-post","status-publish","format-standard","hentry","category-blog","tag-cpanel","tag-disable-directory-listing-in-cpanel-with-apache"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Disable Directory Listing in cPanel with Apache<\/title>\n<meta name=\"description\" content=\"Learn How to Disable Directory Listing in cPanel with Apache to protect your website&#039;s files and enhance security easily.\" \/>\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.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Disable Directory Listing in cPanel with Apache\" \/>\n<meta property=\"og:description\" content=\"Learn How to Disable Directory Listing in cPanel with Apache to protect your website&#039;s files and enhance security easily.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/\" \/>\n<meta property=\"og:site_name\" content=\"Server Management Services | Cloud Management | Skynats\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/skynats\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-12T13:04:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-12T13:04:53+00:00\" \/>\n<meta name=\"author\" content=\"Sourav AJ\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:site\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sourav AJ\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/\"},\"author\":{\"name\":\"Sourav AJ\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/255d12fc66a62db365022ecbb5846276\"},\"headline\":\"How to Disable Directory Listing in cPanel with Apache\",\"datePublished\":\"2025-02-12T13:04:50+00:00\",\"dateModified\":\"2025-02-12T13:04:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/\"},\"wordCount\":429,\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"keywords\":[\"cpanel\",\"Disable Directory Listing in cPanel with Apache\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/\",\"name\":\"How to Disable Directory Listing in cPanel with Apache\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\"},\"datePublished\":\"2025-02-12T13:04:50+00:00\",\"dateModified\":\"2025-02-12T13:04:53+00:00\",\"description\":\"Learn How to Disable Directory Listing in cPanel with Apache to protect your website's files and enhance security easily.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-disable-directory-listing-in-cpanel-with-apache\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Disable Directory Listing in cPanel with Apache\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"name\":\"Server Management Services | Cloud Management | Skynats\",\"description\":\"Server Management and Cloud Management\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\",\"name\":\"Skynats Technologies\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"contentUrl\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"width\":989,\"height\":367,\"caption\":\"Skynats Technologies\"},\"image\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/skynats\",\"https:\\\/\\\/x.com\\\/skynatstech\",\"https:\\\/\\\/www.instagram.com\\\/skynatstech\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/skynats-technologies\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCvTAjrFJ4_E2MJKwlDHomlg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/255d12fc66a62db365022ecbb5846276\",\"name\":\"Sourav AJ\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g\",\"caption\":\"Sourav AJ\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Disable Directory Listing in cPanel with Apache","description":"Learn How to Disable Directory Listing in cPanel with Apache to protect your website's files and enhance security easily.","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.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/","og_locale":"en_US","og_type":"article","og_title":"How to Disable Directory Listing in cPanel with Apache","og_description":"Learn How to Disable Directory Listing in cPanel with Apache to protect your website's files and enhance security easily.","og_url":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/","og_site_name":"Server Management Services | Cloud Management | Skynats","article_publisher":"https:\/\/www.facebook.com\/skynats","article_published_time":"2025-02-12T13:04:50+00:00","article_modified_time":"2025-02-12T13:04:53+00:00","author":"Sourav AJ","twitter_card":"summary_large_image","twitter_creator":"@skynatstech","twitter_site":"@skynatstech","twitter_misc":{"Written by":"Sourav AJ","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/#article","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/"},"author":{"name":"Sourav AJ","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/255d12fc66a62db365022ecbb5846276"},"headline":"How to Disable Directory Listing in cPanel with Apache","datePublished":"2025-02-12T13:04:50+00:00","dateModified":"2025-02-12T13:04:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/"},"wordCount":429,"publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"keywords":["cpanel","Disable Directory Listing in cPanel with Apache"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/","url":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/","name":"How to Disable Directory Listing in cPanel with Apache","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/#website"},"datePublished":"2025-02-12T13:04:50+00:00","dateModified":"2025-02-12T13:04:53+00:00","description":"Learn How to Disable Directory Listing in cPanel with Apache to protect your website's files and enhance security easily.","breadcrumb":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.skynats.com\/blog\/how-to-disable-directory-listing-in-cpanel-with-apache\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.skynats.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Disable Directory Listing in cPanel with Apache"}]},{"@type":"WebSite","@id":"https:\/\/www.skynats.com\/blog\/#website","url":"https:\/\/www.skynats.com\/blog\/","name":"Server Management Services | Cloud Management | Skynats","description":"Server Management and Cloud Management","publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.skynats.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.skynats.com\/blog\/#organization","name":"Skynats Technologies","url":"https:\/\/www.skynats.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","contentUrl":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","width":989,"height":367,"caption":"Skynats Technologies"},"image":{"@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/skynats","https:\/\/x.com\/skynatstech","https:\/\/www.instagram.com\/skynatstech\/","https:\/\/www.linkedin.com\/company\/skynats-technologies","https:\/\/www.youtube.com\/channel\/UCvTAjrFJ4_E2MJKwlDHomlg"]},{"@type":"Person","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/255d12fc66a62db365022ecbb5846276","name":"Sourav AJ","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4a121e24658559577bd8d7ee7d696b05d5908df88dd32a6dfac5311f6fe26b86?s=96&d=mm&r=g","caption":"Sourav AJ"}}]}},"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/14232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=14232"}],"version-history":[{"count":0,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/14232\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=14232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=14232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=14232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}