Proudly Hosting over 100,000 Fast Websites since 2010

How can we help you?

Type your topic or keywords and hit enter to search our knowledgebase.

How to Disable Directory Browsing Using the htaccess Rule

For security purposes, you should disable directory browsing on your website so no one can see the files/directories of your website.

You can disable Directory Browsing by adding the below line to your dot htaccess file.

Options -Indexes
Disabling directory browsing using the .htaccess file is a common practice to enhance the security of your website. When directory browsing is enabled, anyone can see the contents of directories on your web server, which might include sensitive information or files you don't want to be publicly accessible. Disabling it ensures that visitors can't browse through the files and directories of your website.
Here's a step-by-step explanation of how to disable directory browsing using the .htaccess file:
Accessing Your Server: Firstly, you need to have access to your website's files on the server. This is usually done via FTP (File Transfer Protocol) or through a file manager provided by your hosting provider.
Locate or Create the .htaccess File: The .htaccess file is a configuration file used by Apache web servers to modify the server configuration on a per-directory basis. If you already have an .htaccess file in the root directory of your website, you can use that. Otherwise, you'll need to create a new one.
Edit the .htaccess File: Open the .htaccess file using a text editor. You can use any text editor like Notepad (on Windows), TextEdit (on macOS), or any code editor like Sublime Text, Atom, or Visual Studio Code.
Adding the Rule: To disable directory browsing, you'll need to add a specific rule to the .htaccess file. The rule is:
Image disable directoy 
This line tells Apache to disable directory browsing (-Indexes).
Save the Changes: After adding the rule, save the changes to the .htaccess file.
Upload or Update: If you're using an FTP client, upload the modified .htaccess file to the root directory of your website. If you're using a file manager provided by your hosting provider, simply save the changes.
Verify: To make sure directory browsing is disabled, try accessing a directory on your website using a web browser. You should see a message like "403 Forbidden" instead of a list of files and directories.
That's it! By following these steps, you've successfully disabled directory browsing using the .htaccess file. This helps enhance the security of your website by preventing unauthorized access to directory contents.

Updated on April 29, 2024