Stopping Display of All files on Web page | Bluehost Support
Support
  1. bluehost knowledge base

Stopping Display of All files on Web page

Sometimes, for one reason or another, you will have no index file in your directory. This will mean that if someone types the directory name into their browser, the Index of / page will appear with a full listing of all the files in that directory. This could be a security risk for your site.



Accessing your .htaccess file

The fastest and easiest way to edit a .htaccess file for most people is to use the File Manager in cPanel. This article covers how-to edit it using this method. 

Important: Before we do anything, it is suggested that you backup your website so that you can revert to a previous version if something goes wrong.

Bluerock

  1. Log in to your Bluehost control panel.
  2. Click the Advanced tab on the left-hand side menu.
    rock-bh-advanced-tab
  3. Under the File section, click the File Manager icon.
    rock-bluehost-file-filemanager
  4. Look for the Settings button located towards the upper right corner of your screen.
  5. Then click the Preferences popup and then click the checkbox for Show Hidden Files (dotfiles).
    rock-file-manager-preferences
  6. Scroll to locate the .htaccess file from the list.
  7. Right-click on the file, then click on Edit from the menu.
  8. A dialogue box may appear asking you about encoding; click on the Edit button to continue. The editor will open in a new window.
  9. Edit the file as needed, then click the Save Changes button.
  10. Test your website to make sure it has the desired effect. If not, correct the error or revert to the previous version until your site works again.

Legacy

  1. Log in to your Bluehost control panel.
  2. Click the File Manager icon located in the file section.
    legacy-file-manager
  3. Choose the folder you would like to open from the file manager popup settings, most often the WebRoot (public_html/www).
  4. Under the Preferences, make sure the Show hidden files option is checked.
    legacy-file-show-hidden-files

    Note: If you do not see this popup, you will need to click the reset all interface settings link at the bottom of the cPanel page.

  5. Click the Submit button.
  6. The File Manager will open in a new tab or window.
  7. Look for the .htaccess file in the list of files. You may need to scroll to find this file.
  8. Right-click on the file and click on Code Edit from the menu. (Alternatively, you can click on the icon for the .htaccess file and then click on the "Code Editor" icon at the top of the page.)
  9. A dialogue box may appear asking you about encoding. Just click on the Edit button to continue. 
    The editor will open in a new window.
  10. Edit the file as needed.
  11. Click on the Save Changes button in the upper right-hand corner when done. 
    The changes have been saved. Test your website to make sure it has the desired effect. If not, correct the error or revert to the previous version until your site works again.
  12. Once complete, you can click Close to close the window.

Stop a Directory Index From Being Shown

Once you're done creating a backup copy of your .htaccess file and accessing it on your cPanel, enter the following command into your .htaccess file to stop the directory list from being shown:


Options -Indexes

Here is another example if the first command does not work, make sure to remove the first one and replace it with the new command below:


  # disable directory browsing

Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes

# enable directory browsing
Options All +Indexes