Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come disabilitare la navigazione delle directory in WordPress

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

Volete disabilitare la navigazione nelle directory in WordPress?

La navigazione nelle directory può mettere a rischio il vostro sito mostrando agli hacker informazioni importanti che possono essere utilizzate per sfruttare le vulnerabilità nei plugin, nei temi o persino nel server di hosting del vostro sito.

In questo articolo vi mostreremo come disabilitare la navigazione nelle directory in WordPress.

How to disable directory browsing in WordPress

Che cosa fa la disabilitazione della navigazione di directory in WordPress?

Ogni volta che qualcuno visita il vostro sito web, il vostro server web elabora la richiesta.

Di solito, il server consegna al browser del visitatore un file di indice, come index.html. Tuttavia, se il server non riesce a trovare un file di indice, può mostrare tutti i file e le cartelle della directory richiesta.

Si tratta della navigazione nelle directory, spesso attivata per impostazione predefinita.

Se avete mai visitato un sito e avete visto un elenco di file e cartelle invece di una pagina web, avete visto la navigazione nelle directory in azione.

A WordPress site with directory browsing enabled

Il problema è che gli hacker possono utilizzare l’esplorazione delle directory per vedere i file che compongono il vostro sito web, compresi tutti i temi e i plugin che state utilizzando.

Se uno di questi temi o plugin presenta vulnerabilità note, gli hacker possono utilizzare queste conoscenze per prendere il controllo del vostro blog o sito web WordPress, rubare i vostri dati o eseguire altre azioni.

Gli aggressori possono anche utilizzare l’esplorazione delle directory per esaminare le informazioni riservate contenute nei vostri file e cartelle. Potrebbero anche copiare i contenuti del vostro sito web, compresi quelli che di solito fate pagare, come i download di ebook o i corsi online.

Per questo motivo è considerata una buona pratica disabilitare la navigazione nelle directory in WordPress.

Come verificare se la navigazione in directory è abilitata in WordPress

Il modo più semplice per verificare se l’esplorazione delle directory è attualmente abilitata per il vostro sito WordPress è quello di visitare semplicemente il collegamento alla cartella /wp-includes/, in questo modo: https://example.com/wp-includes/.

Sostituite www.example.com con l’URL del vostro sito web.

Se viene visualizzato un messaggio 403 Forbidden o simile, la navigazione nelle directory è già disabilitata sul vostro sito WordPress.

A website with directory browsing disabled

Se invece viene visualizzato un elenco di file e cartelle, significa che la navigazione nelle directory è abilitata per il sito web.

A WordPress site with directory browsing enabled

Poiché questo rende il vostro sito web più vulnerabile agli attacchi, in genere si consiglia di bloccare la navigazione nelle directory in WordPress.

Come disabilitare la navigazione delle directory in WordPress

Per disabilitare l’elenco delle directory, è necessario aggiungere del codice al file .htaccess del sito.

Per accedere al file, è necessario un client FTP, oppure si può utilizzare l’applicazione di gestione dei file all’interno del pannello di controllo del proprio hosting WordPress.

Se è la prima volta che utilizzate l’FTP, potete consultare la nostra guida completa su come connettersi al vostro sito utilizzando l’FTP.

Dopo essersi collegati al sito, è sufficiente aprire la cartella “public” del sito e trovare il file .htaccess. È possibile modificare il file .htaccess scaricandolo sul desktop e aprendolo in un editor di testo come Notepad.

In fondo al file, è sufficiente aggiungere il seguente codice:

Options -Indexes

Avrà un aspetto simile a questo:

The WordPress .htaccess file

Una volta terminato, salvate il file .htaccess e caricatelo sul vostro server utilizzando un client FTP.

Questo è quanto. Ora se si visita lo stesso URL http://example.com/wp-includes/, si otterrà un messaggio 403 Forbidden o simile.

How to disable directory browsing in WordPress

Speriamo che questo articolo vi abbia aiutato a capire come disabilitare la navigazione nelle directory in WordPress. Potreste anche voler consultare la nostra guida definitiva alla sicurezza di WordPress, o vedere la nostra scelta di esperti del miglior plugin per l’iscrizione a WordPress per proteggere i vostri file.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

94 commentiLascia una risposta

  1. 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!

  2. Jiří Vaněk says

    Thanks for the advice. On directory browsing, or that I have it enabled, the AIO SEO plugin keeps warning me. I have currently solved the problem by making the folders have an index file that is empty. Is it possible to take this as one of the possible solutions?

      • Jiří Vaněk says

        Thanks for the advice, I finally used the Options -Indexes method now and AIO SEO already reports the problem as solved. Thanks again.

  3. Ka Khaliq says

    After editing the htaccess file as per the provided guidelines, I do see 403 Forbidden message for /wp-includes/. But I’m unable to see edit any post. Upon editing a post, I see the same 403 Forbidden message. How to solve this?

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

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

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

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

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

      Admin

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

      Admin

  10. 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]

  11. 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?

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

  13. 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!

  14. 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!

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

  15. Kim says

    Sorry to late ask. I want to know, are these techniques safe to use regarding SEO score ? Hope you answer !

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

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

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

  19. nitai says

    Really great. today I just faced and thinking how can I disallow like joomla and I found the exact solution.

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

  21. 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. :)

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

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

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

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.