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

Så här inaktiverar du browsing i directories i WordPress

Vill du inaktivera directory browsing i WordPress?

Directory browsing kan utsätta din site för risker genom att visa viktig information för hackare, som kan användas för att utnyttja sårbarheter i din sites tillägg, themes eller till och med din webbhotell server.

I den här artikeln visar vi dig hur du inaktiverar browsing av directory i WordPress.

How to disable directory browsing in WordPress

Vad innebär det att inaktivera Directory Browsing i WordPress?

Varje gång någon besöker din website kommer din web server att behandla denna request.

Vanligtvis levererar servern en indexfil till besökarens webbläsare, till exempel index.html. Om servern inte hittar någon indexfil kan den i stället visa alla filer och foldrar i den directory som requestats.

Detta anropas directory browsing, och det är ofta aktiverat som standard på ditt webbhotell server.

Om du någonsin har besökt en site och sett en lista med filer och foldrar istället för en webbsida, då har du sett directory browsing i action.

A WordPress site with directory browsing enabled

Problemet är att hackare kan använda directory browsing för att se filerna som utgör din website, inklusive alla teman och tillägg som du använder.

Om något av dessa themes eller tillägg har kända sårbarheter kan hackare använda denna kunskap för att ta kontroll över din WordPress blogg eller website, stjäla dina data eller utföra andra actions.

Angripare kan också använda directory browsing för att klura på den konfidentiella informationen i dina filer och foldrar. De kan till och med kopiera innehållet på din website, inklusive content som du vanligtvis tar betalt för, t.ex. download av e-böcker eller onlinekurser.

Det är därför det anses vara en bästa praxis att inaktivera directory browsing i WordPress.

Hur kontrollerar man om Directory Browsing är aktiverat i WordPress?

Det enklaste sättet att kontrollera om directory browsing för närvarande är aktiverat för din WordPress website är att helt enkelt besöka länken till /wp-includes/ folder så här: https://example.com/wp-includes/.

Du ska ersätta www.example.com med URL:en till din website.

Om du får ett 403 Forbidden eller liknande message, är directory browsing redan inaktiverat på din WordPress website.

A website with directory browsing disabled

Om du istället ser en lista med filer och foldrar betyder det att directory browsing är aktiverad för din website.

A WordPress site with directory browsing enabled

Eftersom detta gör din website mer sårbar för attacker, vill du vanligtvis blockera directory browsing i WordPress.

Så här inaktiverar du browsing i directories i WordPress

Om du vill inaktivera listning av directory måste du add to en kod i .htaccess-filen på din site.

För att komma åt filen behöver du en FTP-klient, eller så kan du använda appen för filhantering i kontrollpanelen på ditt WordPress webbhotell.

Om det är första gången du använder FTP kan du läsa vår kompletta guide om hur du ansluter till din site med FTP.

När du har anslutit till din webbplats öppnar du bara webbplatsens ”offentliga” folder och hittar .htaccess-filen. You can edit the .htaccess file by downloading it to your desktop and then opening it in a text editor like Notepad.

Längst ner i filen lägger du helt enkelt till följande kod:

Options -Indexes

Det kommer att se ut ungefär så här:

The WordPress .htaccess file

När du är klar, save din .htaccess-fil och uploada den tillbaka till din server med hjälp av en FTP-klient.

Så där, ja. Om du nu besöker samma URL http://example.com/wp-includes/ får du ett 403 Forbidden eller liknande message.

How to disable directory browsing in WordPress

Experttips: Om du misstänker att din WordPress-webbplats kan ha blivit hackad, se vår guide om hur du fixar en hackad WordPress-webbplats. Alternativt kan du ta en titt på vår professionella reparationstjänst för hackade WordPress -webbplatser och anlita professionella WordPress-säkerhetsexperter för att rensa din website.

Vi hoppas att den här artikeln hjälpte dig att lära dig hur du inaktiverar directory browsing i WordPress. Du kanske också vill läsa vår ultimata guide till säkerhet i WordPress eller se vårt expertval av de bästa tilläggen för säkerhet i 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.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

98 kommentarerLämna ett svar

  1. Dennis Muthomi

    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?

    • WPBeginner Support

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

      Administratör

      • Dennis Muthomi

        That’s what I was suspecting also, thanks for clarifying that WordPress doesn’t disable directory browsing by default.
        And the respond too :)

  2. Dayo Olobayo

    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.

    • WPBeginner Support

      You’re welcome :)

      Administratör

  3. Jiří Vaněk

    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?

    • WPBeginner Support

      You can try that method but we would still recommend the htaccess method from our guide.

      Administratör

      • Jiří Vaněk

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

  4. Ka Khaliq

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

    Thank you so much! Clear, concise, and easy to follow. Thank you so much!

    • WPBeginner Support

      You’re welcome!

      Administratör

  6. Rabee Khan

    Thank You… precise and easy to understand!

    • WPBeginner Support

      Glad our guide was helpful!

      Administratör

  7. Kimmy

    Thanks for the two-word solution! Lol. Worked perfectly!

    • WPBeginner Support

      Glad we could help! :)

      Administratör

  8. Seashell

    I was shocked to see the folders accessible right in the browser.
    Thanks for your solution!

    • WPBeginner Support

      Glad we could help! :)

      Administratör

  9. Deepak Kumar

    Its work like charm. Article on wpbeginners like ready to go solution. Keep it up.

  10. Ayo

    How do I now solve the 404 error that comes after?

  11. Pradip Singh

    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

      Glad you found our content helpful :)

      Administratör

  12. Sourabh

    Will it block CDNs from accessing my website for static content?

    • WPBeginner Support

      No, it will not.

      Administratör

  13. sami

    Does this method affect google crawling .. is it SEO friendly?

    • WPBeginner Support

      It should not affect search engines crawling your site.

      Administratör

  14. Meera Shaikh

    Thanks its Done

    • WPBeginner Support

      You’re welcome :)

      Administratör

  15. Pradeep

    Thanks my friend, I just try this and it’s work.
    You are the genius.

    • WPBeginner Support

      Glad our guide was helpful :)

      Administratör

  16. mousam

    Thank you. I applied and it worked.
    You guys are the best source for learning wordpress.

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  17. Kevine

    Thank you very much for this. It solved my problem.

    Thanks again.

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  18. malika

    Thank you for sharing information!

    • WPBeginner Support

      You’re welcome :)

      Administratör

  19. Jonthan

    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

      Yes :)

      Administratör

  20. Teresa Cuervo

    Do you need Filezila to do this or can you go to the FTP via Cpanel and do this?
    Thank you

    • WPBeginner Support

      You can use either, not all hosts have a file manager is why we show Filezilla :)

      Administratör

  21. michael

    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

      No, it would not affect that negatively.

      Administratör

  22. Rhen Castrodes

    Thank you. it works

    • WPBeginner Support

      Glad our recommendation was able to help you :)

      Administratör

  23. John

    Thank you! It works even now in 2020.

    • WPBeginner Support

      You’re welcome :)

      Administratör

  24. Shams

    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

      This code should not make your direct links to images and files turn into 404s

      Administratör

  25. Bill

    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

      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.

      Administratör

  26. Ionel G

    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

      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.

      Administratör

  27. Mayur

    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]

  28. Rafael

    Thank you. Worked perfectly for all browsers.

  29. Dipankar

    but wp-content is showing . how to remove it as well.

  30. Deatram

    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?

  31. Faeze

    I added the line that you said in .htaccess but it showes my directories yet .
    What should I do now??

  32. Nathan

    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

  33. Tôi Sống

    Awesome, it work very good!

  34. Baggio

    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!

  35. daniel

    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

      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.

      Administratör

      • Axel Jebens

        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?

  36. Ünal Hoca

    Thank you

  37. Khalid Mahmud

    Thank you. It’s working…….

  38. Kim

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

  39. Kimmy

    Still works pretty well. Awesome, simple, and working. Thanks!

  40. Charles

    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

      What part are you having trouble on? What is your hosting provider btw?

  41. Lily

    Thank you. Worked like a charm!

  42. Prakash

    This Above Trick Is Not Working Man….

  43. Mike

    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.

  44. Christian Nastari

    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

  45. hrwhisper

    very helpful, thank you very much

  46. nitai

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

  47. Rob Myrick

    This was very helpful and quick – thank you

  48. Anita in SD

    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

  49. Heather Jacobsen

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

  50. Wasil Burki

    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

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.