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

Jak wyłączyć przeglądanie katalogów w WordPress

Widzieliśmy wiele witryn internetowych, które nie wyłączają przeglądania katalogów. Niestety, ten drobny błąd może narazić poufne informacje na ataki hakerów i zaszkodzić witrynie internetowej.

Przeglądanie katalogów pozwala innym osobom zobaczyć pliki i katalogi twojej witryny. Hakerzy mogą następnie wykorzystać te informacje do znalezienia luk w zabezpieczeniach wtyczek, motywów lub twojego serwera hostingowego.

Wykonanie tego prostego kroku może znacznie poprawić zabezpieczenia twojej witryny. To szybka poprawka, którą powinien znać każdy właściciel witryny internetowej.

W tym przewodniku pokażemy, jak wyłączyć przeglądanie katalogów w WordPress. Pomoże to zabezpieczyć twoją witrynę i zapewnić bezpieczeństwo danych.

How to disable directory browsing in WordPress

Co robi wyłączenie przeglądania katalogów w WordPress?

Gdy odwiedzający uzyskuje dostęp do witryny internetowej, serwer WWW przetwarza jego żądanie. Zazwyczaj serwer dostarcza do przeglądarki plik indeksu, taki jak index.html.

Jeśli brakuje pliku indeksu, serwer może wyświetlić listę wszystkich plików i katalogów w tym katalogu. To zachowanie, znane jako przeglądanie katalogów, jest domyślnie włączone na serwerach hostingowych.

Widzieliśmy na własne oczy, jak przeglądanie katalogów może ujawnić poufne informacje o strukturze witryny. Informacje te mogą zostać wykorzystane do zidentyfikowania luk w zabezpieczeniach wtyczek, motywów, a nawet konfiguracji hostingu.

Odwiedzający mogą natknąć się na przeglądanie katalogów, gdy zamiast strony internetowej zobaczą zwykłą listę plików i katalogów. Ten niezamierzony dostęp może prowadzić do zagrożeń bezpieczeństwa, jeśli nie zostaną podjęte odpowiednie działania.

Directory browsing enabled

Hakerzy często wykorzystują przeglądanie katalogów, aby zobaczyć pliki witryny, w tym motywy i wtyczki. Jeśli którykolwiek z nich ma znane luki w zabezpieczeniach, atakujący mogą wykorzystać te informacje do naruszenia bezpieczeństwa witryny internetowej.

W wielu przypadkach przeglądanie katalogów może również ujawnić prywatne lub płatne treści, takie jak pobrane ebooki lub kursy online. Może to prowadzić do nieautoryzowanego kopiowania i utraty przychodów.

Wyłączenie przeglądania katalogów jest prostym, ale skutecznym sposobem zapobiegania tym zagrożeniom. Jest to jeden z pierwszych kroków, które zalecamy w celu zabezpieczenia witryny WordPress.

Jak sprawdzić, czy przeglądanie katalogów jest włączone w WordPress?

Łatwym sposobem na sprawdzenie, czy przeglądanie katalogów jest włączone na twojej witrynie internetowej WordPress, jest bezpośrednie przejście na katalog /wp-includes/.

Na przykład, wpisz adres URL taki jak ten: https://example.com/wp-includes/ w twojej przeglądarce.

Upewnij się, że zastąpiłeś example.com rzeczywistą nazwą domeny twojej witryny internetowej. Ten prosty test działa w przypadku większości instalacji WordPress.

Jeśli zobaczysz komunikat 403 Forbidden lub podobny błąd, przeglądanie katalogów jest już wyłączone. To dobry znak, ponieważ oznacza to, że twoja witryna internetowa jest lepiej zabezpieczona.

403 forbidden page is displayed when directory browsing is disabled

Jeśli zamiast tego pojawi się lista plików i katalogów, oznacza to, że przeglądanie katalogów jest włączone.

Jest to coś, co sprawia, że witryny internetowe są podatne na złośliwe ataki.

Directory browsing enabled

Z naszego doświadczenia wynika, że włączanie przeglądania katalogów naraża poufne informacje i zwiększa ryzyko związane z zabezpieczeniami. Z tego powodu najlepiej jest wyłączyć przeglądanie katalogów w WordPress, aby Twoja witryna była bezpieczna.

Jak wyłączyć przeglądanie katalogów w WordPress

Aby wyłączyć listowanie katalogów, musisz dodać kod do pliku .htaccess twojej witryny.

Aby uzyskać dostęp do pliku, będziesz potrzebował klienta FTP lub możesz użyć aplikacji menedżera plików w panelu sterowania hostingu WordPress.

Jeśli po raz pierwszy korzystasz z FTP, zapoznaj się z naszym kompletnym przewodnikiem na temat łączenia się z witryną za pomocą FTP.

Po połączeniu się z twoją witryną, po prostu otwórz jej katalog publiczny i znajdź plik .htaccess. Następnie możesz edytować plik .ht access, pobierając go na twój pulpit, a następnie otwierając go w edytorze tekstu, takim jak Notatnik.

Na samym dole pliku wystarczy dodać następujący kod:

Options -Indexes

Będzie to wyglądać mniej więcej tak:

Added border to an image

Gdy skończysz, zapisz plik .htaccess i prześlij go z powrotem na twój serwer za pomocą klienta FTP.

To wszystko. Teraz, jeśli przejdziesz na ten sam adres URL http://example.com/wp-includes/, otrzymasz komunikat 403 Forbidden lub podobny.

403 forbidden page is displayed when directory browsing is disabled

Porada eksperta : Jeśli podejrzewasz, że twoja witryna WordPress mogła zostać zhakowana, zapoznaj się z naszym przewodnikiem na temat poprawki zhakowanej witryny WordPress. Alternatywnie, możesz wybrać naszą profesjonalną usługę naprawy zhakowanej witryny WordPress i zatrudnić profesjonalnych ekspertów ds. zabezpieczeń WordPress, którzy od razu wyczyszczą twoją witrynę.

Dodatkowa lektura:

Chcesz, aby twoja witryna internetowa WordPress była zabezpieczona i wolna od błędów? Poniższe artykuły mogą okazać się przydatne:

Mamy nadzieję, że ten artykuł pomógł ci dowiedzieć się, jak wyłączyć przeglądanie katalogów w WordPress. Możesz również zapoznać się z naszym kompletnym przewodnikiem po zabezpieczeniach WordPress lub zobaczyć naszą ekspercką listę najlepszych wtyczek zabezpieczających WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

97 komentarzyLeave a Reply

  1. I noticed that I have directory browsing disabled on my WordPress site, because I got a 403 error when trying to access wp-includes, yet I don’t remember ever having edited my .htaccess file to do so.
    Does WordPress automatically disable directory browsing during initial installation?

    • Unless there was a recent change it does not by default, it may be your hosting provider’s default settings for htaccess.

      Admin

  2. I didn’t even know that this vulnerability existed. Just checked mine and got the 403 error. which means directory browsing is disabled. Thank you.

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

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

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

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

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

  7. Hello
    does this action affect pages indexing on search engines?
    and does it make some problems for indexed pages of my WordPress website?
    Thanks

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

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

    • 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

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

    • 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

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

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

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

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

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

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

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

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

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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.