Blog | G5 Cyber Security

Fix Browser Root Directory Access

TL;DR

Your website is letting people see files they shouldn’t because of a misconfigured web server. This guide shows you how to fix it, usually by setting up an index file or redirecting requests.

Understanding the Problem

When someone types your domain name (e.g., example.com) into their browser without specifying a specific page (like example.com/about), the web server looks for a default file to serve. Common defaults are index.html, index.php, or default.htm. If none of these exist, and your server isn’t configured correctly, it might list all the files in your website’s root directory – which is a major security risk.

Solution

  1. Check for an Index File:
  • Configure Your Web Server (Apache):
  • DirectoryIndex index.html index.php default.htm
  • After making changes, restart Apache to apply them. On Debian/Ubuntu systems:
    sudo systemctl restart apache2

    On CentOS/RHEL systems:

    sudo systemctl restart httpd
  • Configure Your Web Server (Nginx):
  • index index.html index.php;
  • After making changes, test the configuration and reload Nginx:
    sudo nginx -t
    sudo systemctl reload nginx
  • Redirect Requests (Alternative):
  • Check File Permissions:
  • Testing

    After making any changes, clear your browser’s cache and try visiting your domain name without specifying a page (e.g., example.com). You should either see your index file or be redirected to the specified URL. If you still see a directory listing, double-check your configuration files and server logs for errors.

    Exit mobile version