Voulez-vous désactiver la navigation dans les répertoires dans WordPress ?
La navigation dans les répertoires peut mettre votre site en danger en affichant des informations importantes aux pirates, qui peuvent être utilisées pour exploiter des vulnérabilités dans les extensions, les thèmes ou même le serveur d’hébergement de votre site.
Dans cet article, nous allons vous afficher comment vous pouvez désactiver la navigation dans les répertoires sur WordPress.
Quel est l’effet de la désactivation de la navigation dans les répertoires sur WordPress ?
Chaque fois que quelqu’un visite votre site, votre serveur web traite cette demande.
En général, le serveur envoie un fichier d’index au navigateur de l’internaute, tel que index.html. Toutefois, si le serveur ne trouve pas de fichier index, il peut afficher tous les fichiers et dossiers du répertoire demandé.
Il s’agit de la navigation dans les répertoires, souvent activée par défaut.
Si vous avez déjà visité un site et vu une liste de fichiers et de dossiers au lieu d’une page web, vous avez vu la navigation dans les répertoires en action.
Le problème est que les pirates peuvent utiliser la navigation dans les répertoires pour voir les fichiers qui composent votre site, y compris tous les thèmes et extensions que vous utilisez.
Si l’un de ces thèmes ou extensions présente des vulnérabilités connues, les pirates peuvent alors utiliser ces connaissances pour prendre le contrôle de votre blog ou site WordPress, voler vos données ou effectuer d’autres actions.
Les attaquants peuvent également utiliser la navigation dans les répertoires pour consulter les informations confidentielles contenues dans vos fichiers et dossiers. Ils peuvent même copier le contenu de votre site, y compris le contenu que vous feriez habituellement payer, comme les téléchargements d’ebooks ou les cours en ligne.
C’est pourquoi il est considéré comme une bonne pratique de désactiver la navigation dans les répertoires dans WordPress.
Comment vérifier si la navigation dans les répertoires est activée dans WordPress
La façon la plus simple de vérifier si la navigation dans les répertoires est actuellement activée pour votre site WordPress est de visiter le lien du dossier /wp-includes/ comme ceci : https://example.com/wp-includes/.
Remplacez www.example.com par l’URL de votre site.
Si vous obtenez un message 403 Forbidden ou un message similaire, c’est que la navigation dans les répertoires est déjà désactivée sur votre site WordPress.
Si vous voyez une liste de fichiers et de dossiers à la place, cela signifie que la navigation dans les répertoires est activée pour votre site.
Comme cela rend votre site plus vulnérable aux attaques, vous voudrez généralement bloquer la navigation dans les répertoires dans WordPress.
Comment désactiver la navigation dans les répertoires sur WordPress
Pour désactiver l’inscription au répertoire, vous devez ajouter du code au fichier .htaccess de votre site.
Pour accéder au fichier, vous aurez besoin d’un client FTP, ou vous pouvez utiliser l’application de gestion de fichiers dans le panneau de contrôle de votre hébergeur WordPress.
Si c’est la première fois que vous utilisez le protocole FTP, vous pouvez consulter notre guide complet sur la façon de se connecter à votre site à l’aide du protocole FTP.
Après vous être connecté à votre site, ouvrez simplement le dossier « public » de votre site et trouvez le fichier .htaccess. Vous pouvez modifier le fichier .htaccess en le téléchargeant sur votre ordinateur, puis en l’ouvrant dans un éditeur/éditrices de texte tel que le Bloc-notes.
Tout en bas du fichier, il suffit d’ajouter le code suivant :
Options -Indexes
Il se présentera comme suit :
Une fois que vous avez terminé, enregistrez votre fichier .htaccess et téléversez-le sur votre serveur à l’aide d’un client FTP.
Voilà, c’est fait. Maintenant, si vous visitez la même URL http://example.com/wp-includes/, vous obtiendrez un message 403 Forbidden ou un message similaire.
Nous espérons que cet article vous a aidé à apprendre comment désactiver la navigation dans les répertoires sur WordPress. Vous pouvez également consulter notre guide ultime de sécurité WordPress, ou voir notre choix d’expert du meilleur plugin d’adhésion WordPress pour protéger vos fichiers.
Si vous avez aimé cet article, veuillez alors vous abonner à notre chaîne YouTube pour obtenir des tutoriels vidéo sur WordPress. Vous pouvez également nous trouver sur Twitter et Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Deepak Kumar says
Its work like charm. Article on wpbeginners like ready to go solution. Keep it up.
Ayo says
How do I now solve the 404 error that comes after?
Pradip Singh says
I am in love with this website. Every day I am surprised when I read a new article from this website. Thankfully I read this article today and immediately I implemented the advice.
WPBeginner Support says
Glad you found our content helpful
Administrateur
Sourabh says
Will it block CDNs from accessing my website for static content?
WPBeginner Support says
No, it will not.
Administrateur
sami says
Does this method affect google crawling .. is it SEO friendly?
WPBeginner Support says
It should not affect search engines crawling your site.
Administrateur
Meera Shaikh says
Thanks its Done
WPBeginner Support says
You’re welcome
Administrateur
Pradeep says
Thanks my friend, I just try this and it’s work.
You are the genius.
WPBeginner Support says
Glad our guide was helpful
Administrateur
mousam says
Thank you. I applied and it worked.
You guys are the best source for learning wordpress.
WPBeginner Support says
You’re welcome, glad our guide was helpful
Administrateur
Kevine says
Thank you very much for this. It solved my problem.
Thanks again.
WPBeginner Support says
You’re welcome, glad our guide was helpful
Administrateur
malika says
Thank you for sharing information!
WPBeginner Support says
You’re welcome
Administrateur
Jonthan says
So is it ok to have this code on .htaccess file even when an index.php file is present in the root folder.
Kindly respond.
WPBeginner Support says
Yes
Administrateur
Teresa Cuervo says
Do you need Filezila to do this or can you go to the FTP via Cpanel and do this?
Thank you
WPBeginner Support says
You can use either, not all hosts have a file manager is why we show Filezilla
Administrateur
michael says
Hello
does this action affect pages indexing on search engines?
and does it make some problems for indexed pages of my WordPress website?
Thanks
WPBeginner Support says
No, it would not affect that negatively.
Administrateur
Rhen Castrodes says
Thank you. it works
WPBeginner Support says
Glad our recommendation was able to help you
Administrateur
John says
Thank you! It works even now in 2020.
WPBeginner Support says
You’re welcome
Administrateur
Shams says
Amazing post,
Just have simple question, I added this code and it’s working, the question is Google indexes those page e.g sitecom/wp-contents/2019/2, will Google remove those pages automatically now as these are 404. Or I should remove it in Search Console?
Thanks
WPBeginner Support says
This code should not make your direct links to images and files turn into 404s
Administrateur
Bill says
Hello!
I recently applied this rule
and at the same day the front page of my blog
got vanished from google index.
Do you see any connection?
WPBeginner Support says
Adding this to your htaccess should not affect your indexing, there are multiple reasons and you would want to check your Google Search Console for what it says about your home page.
Administrateur
Ionel G says
Thanks for all the tips that you provide!
I am still wondering how can you hide the wp-content & wp-include folder from sources? I hate it when someone goes right click and source it can see all of my plugins :). Do you have any script for this?
Thank you in advance!
WPBeginner Support says
We do not have a recommended method for that at the moment, the most common reason you can’t see those folders in dev tools is a site’s cache.
Administrateur
Mayur says
Could you please tell me How can i disable WordPress in sub folder like my WordPress install on [www.mydomain.com] and i want to disable wordpress in [www.mydomain.com/customscript]
WPBeginner Support says
You may want to first take a look at creating a custom page template: https://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/
Otherwise, you would need to create a folder with that name and inside that folder add an index.html file for a nonWordPress page to appear.
Administrateur
Rafael says
Thank you. Worked perfectly for all browsers.
Dipankar says
but wp-content is showing . how to remove it as well.
Deatram says
I disabled directory browsing, but still someone can see my directory when they use developer tools in chrome browser. How do I disable in that as well?
Faeze says
I added the line that you said in .htaccess but it showes my directories yet .
What should I do now??
Nathan says
When I click « Save Changes » on the Permalink Settings page the .htaccess file is updated, erasing the « Options -Indexes » code that I inputted. The code works fine, but I am concerned I will unknowingly delete it while performing some other task. Are there any other dashboard settings changes that I should know about that may affect the .htaccess file and erase the code? Thanks
Tôi Sống says
Awesome, it work very good!
Baggio says
Huge fan of wpbeginner, Optin Monster – I got so many useful tips and tricks on WP – and I have to say, the site design is just brilliant. And of course, the content here is epicly useful.
Thanks guys!
daniel says
Hey! It doesnt seem to work. if i pull an image to another page its opened with a link of: example.com/wp-content/uploads/…
Any idea? thanks!
WPBeginner Support says
Hey Daniel,
Your images and files inside directories can still be directly accessed. However, server will not let someone directly browse a directory and see its contents.
Administrateur
Axel Jebens says
I would appreciate if you could iterate on this. I had a hard time when trying to get a solution for this issue. There are some ideas based on a htaccess redirecting to a php file that first checks if the user is logged on. Is there any plugin which provides such a function?
Ünal Hoca says
Thank you
Khalid Mahmud says
Thank you. It’s working…….
Kim says
Sorry to late ask. I want to know, are these techniques safe to use regarding SEO score ? Hope you answer !
WPBeginner Support says
Yes, they are.
Administrateur
Kimmy says
Still works pretty well. Awesome, simple, and working. Thanks!
Charles says
I have been writing this same code for weeks now but my directory remains visible to users. Pls what am doing wrong? Or could it be that my site is still loading from cached contents? Everybody says it is working but my own experience is different. Any help will be appreciated! Thanks in anticipation of your reply.
Kimmy says
What part are you having trouble on? What is your hosting provider btw?
Lily says
Thank you. Worked like a charm!
Prakash says
This Above Trick Is Not Working Man….
Mike says
Is there a way to allow viewing a directory but just hide the Parent Directory link for a specific page? This would be a network share folder that multiple people would access, and have sub folders which would still require a parent directory listing. I just don’t want anyone going above the shared folder.
Christian Nastari says
This didn’t work for me. I tried before and after #END WordPress and didn’t work. I also tried « Options All -Indexes », but didn’t work either
hrwhisper says
very helpful, thank you very much
nitai says
Really great. today I just faced and thinking how can I disallow like joomla and I found the exact solution.
Rob Myrick says
This was very helpful and quick – thank you
Anita in SD says
Thanks so much, was dismayed to see images from my site going to a parent directory :0. This was very helpful and worked well.
Blessings – A
Heather Jacobsen says
Thanks for this tutorial. It worked great for hiding my uploads from anyone just wanting to browse that directory. One question, though. Does this by chance turn off the ability of search engines to browse my website. Sorry if it seems like a dumb question. I am a newbie, after all.
Wasil Burki says
I added the Options -Indexes code to the htaccess file, however now I am not able to access the site I get a 503 error. Am I doing something wrong? Need help bad!! Thanks
Ted says
The problem I have is that I can see the directory of this wordpress site, so if you are using this solution then it doesn’t work… (theme wpbv4)
Rahul says
Thank you so much for the tutorial!
I was very concerned when I discovered some of my theme directories could be browsed. All good now, thanks to your tutorial. I never knew .htaccess packed in so much punch.
KeelAha says
Hello Syed Balkhi
I just noticed that one of your site list25.com having directory browsing enabled on following folder.
Not sure if that is important to you.
http://list25.com/wp-includes/
Have a great weekend and keep doing your good work.
regards
KeelAha
WPBeginner Support says
Disabled it, thanks
Administrateur
Logan says
Why do I get a blank page, and not an error when I try to access the ../wordpress/wp-content/ or ../wordpress/wp-content/plugins/ ?
WPBeginner Support says
It may depend on your theme or your hosting environment. Try enabling directory browsing and then access these directories. If you still get a blank page then this means that those directories have a blank index.php file in them.
Administrateur
Charlie Sasser says
I tested this before I made any changes with a location that didn’t have an index.php or .htm file and yes you can see all of the files. I added the suggested line at the end of the .htaccess. The location now creates a 403 error from the host and not a 404 error from WordPress. I’m running WP 3.8. Is this the expected behavior?
Bern says
I have the same issue it shows 403 error not 404. Did you solve this problem?
Christian says
Same issue appear, what to do now? using latest version of wordpress.
Abhisek says
Better WordPress Security plugin takes care of that.
Govinda says
How do I do it in Better Wp security.
I have installed the plugin, but not able to find this feature
Costin says
Hi,
Could you please tell me if « Options All -Indexes » is the same or better?
Thank you!
WPBeginner Support says
Its the same.
Administrateur
David Trees says
Thanks for this important information.
Do you mean;
Here
Options -Indexes
# END WordPress
OR
# END WordPress
Options -Indexes
Thanks for your reply.
Cheers
David
WPBeginner Support says
Both should work the same but we meant the later one after the END WordPress
Administrateur
Ivan R Linares says
Thank you, worked like a charm!