How to hide Directory Browsing in WordPress from server?

  1. Access your website's root directory using an FTP client or a file manager provided by your web hosting control panel.

  2. Locate the ".htaccess" file in your root directory. If you can't find it, ensure that your FTP client or file manager is set to display hidden files.

  3. Download a backup copy of the ".htaccess" file to your local computer before making any changes. This step ensures you can revert to the original file if something goes wrong.

  4. Open the ".htaccess" file using a text editor, such as Notepad on Windows or TextEdit on macOS.

  5. Add the following line of code at the end of the ".htaccess" file: Options -Indexes

  6. Save the changes to the ".htaccess" file and upload it back to your website's root directory, replacing the existing file if prompted.

  7. Verify that directory browsing is disabled by attempting to access a directory on your website via a web browser. You should receive a "403 Forbidden" error instead of a list of files and folders.

  8. Clear your browser cache and revisit your website to ensure it's functioning properly without directory browsing.

  9. Regularly maintain and update your website's security measures to safeguard against potential vulnerabilities.

Remember to exercise caution when editing the ".htaccess" file, as incorrect modifications could potentially lead to website errors or downtime. Always keep a backup of the original file to revert to in case of any issues.