Hide folders with .htaccess

Viewed 63399

Is it possible to hide the folders in my root folder? Just in case my index.php would disappear you know?

Could I also show 404 error not found if someone requests them?

10 Answers

In my case, i did that but it shows me Error 500. This is my .htaccess

RewriteEngine on

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Options - Indexes

Thanks

I used this code:

At your main root .htaccess put the flowing code :

RewriteEngine on
RewriteRule ^dfjgekbjvrskzcnfvberidurvf/?(.*)$    /folder1/$1 [L]


Then at .htaccess file in folder1 directory put this :

RewriteEngine on
RewriteCond %{THE_REQUEST} !dfjgekbjvrskzcnfvberidurvf
RewriteRule ^    - [F,L]

make a file mame .htaccess in the directory where you want to hide folder's list and just this code

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [R=404,L]
Related