Print this page
Saturday, 09 March 2019 11:23

How to disable directory browsing in WordPress

Written by 

Disabling directory browsing in WordPress or any other CMS or website for that matter requires access to the base directory via FTP or some file manager like cPanel.

There are various free FTP clients that will help you here, a good option is FileZilla.

You simply need to create an .htaccess file with the following line of code in it:

Options All -Indexes

Then upload the file back to the respective folder. This is a very general overview of the process. In most cases, you might already have a .htaccess file present inside your WordPress installation directory. It is created when you had changed the permalink settings.

Be very careful – do not overwrite this file, or else you’ll lose all your permalink and other security settings.

If you already have a .htaccess file present, first create a backup. Then, open it in Notepad (or any plain text editor) and paste the following line in the end:

Options All -Indexes

In general, most .htaccess files contain the following code:

 

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress

The modified code will look like:

 

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress

Options All -Indexes

Save the file, and upload it back in the same directory you downloaded it from, this time overwriting the file. If anything breaks, replace it with your backup file and try the process again.

Read 2764 times
CNERIS.COM

Latest from CNERIS.COM

FaLang translation system by Faboba