Disabling directory listing in WordPress

2

Good afternoon everyone, I would like my directory listing not to be exposed, I used the following code inside .htaccess Options -Indexes , however when I test the code renaming the index. php it returns error 403 . Is it possible to display another error screen, or is there another way to do this?

    
asked by anonymous 21.12.2017 / 17:56

2 answers

0

I'm not an expert, and I do not know if that's exactly the answer you want, but I'll give you some tips on what I've seen.

First of all in% of your site

disable directories so that they do not appear in search engines, see example: (directory names will depend on what you have in root)

User-agent: *
Disallow: /administrator/
Disallow: /administrator
Disallow: /cache/
Disallow: /cli/
Disallow: /components/
Disallow: /images/
Disallow: /includes/
Disallow: /installation/
Disallow: /language/
Disallow: /libraries/
Disallow: /logs/
Disallow: /media/
Disallow: /modules/
Disallow: /plugins/
Disallow: /templates/
Disallow: /tmp/

Then create a index.html blank file at the root of each of these directories , so if someone tries to get in directly through the folder path it will fall on a page in white ...

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body></body>
</html>

And finally, try to "masquerade" that you are using WordPress, remove or rename the codes you have written Wordpress, such as robots.txt in <meta name="generator" content="WordPress.com" /> your company.

    
21.12.2017 / 18:12
1

After some research I found a way to not show my directory, follow the step by step:

// I redirected the error to an image where it indicates site under maintenance, and I used the code below to verify //

ErrorDocument 403 / site_em_manutention.png

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(index|index/)$ index.php [NC,L]
    RewriteRule ^index/([a-z0-9-]+)$ index.php/$1 [NC]
</IfModule>
    
21.12.2017 / 18:15