Portal Home Knowledgebase CPanel Stopping display of all files on web page

Stopping display of all files on web page Print

  • 127

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. 

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

Bluerock

  • Log in to your cPanel

 

  • Click the Advanced tab on the left-hand side menu.

 

Under the File section, click the File Manager icon.

  • Look for the Settings button, located towards the upper right corner of your screen.

 

  • Then click the Preferences popup and then click the checkbox for Show Hidden Files (dotfiles).

 

  • Scroll to locate the .htaccess file from the list.

 

  • Right-click on the file, then click on Edit from the menu.

 

  • A dialogue box may appear asking you about encoding; click on the Edit button to continue. The editor will open in a new window.

 

  • Edit the file as needed, then click the Save Changes button.

 

  • 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

  • Log in to your cPanel

Click the File Manager icon, located in the file section.

  • From the file manager popup settings, choose the folder you would like to open, most often the Web Root (public_html/www).

 

  • Under the Preferences, make sure the Show hidden files is checked.

 

  • 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.
  • Click the Submit button.

 

  • The File Manager will open in a new tab or window.

 

  • Look for the .htaccess file in the list of files. You may need to scroll to find this file.

 

  • 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.)

 

  • 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.

 

  • Edit the file as needed.

 

  • 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.

 

  • 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

 

 


Was this answer helpful?

« Back