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

Jak zabezpieczyć hasłem twój katalog administratora WordPress (wp-admin)

Uwaga redakcyjna: Otrzymujemy prowizję z linków partnerskich na WPBeginner. Prowizje nie mają wpływu na opinie i oceny naszych redaktorów. Dowiedz się więcej o Proces redakcyjny.

Chcesz dowiedzieć się, jak zabezpieczyć hasłem twój katalog administracyjny WordPress?

Dodanie kolejnej warstwy zabezpieczenia hasłem do twojego katalogu administracyjnego WordPress może być świetnym sposobem na poprawę bezpieczeństwa WordPress.

W tym artykule dowiesz się, jak łatwo zabezpieczyć hasłem twój katalog wp-admin.

How to Password Protect Your WordPress Admin (wp-admin) Directory

Dlaczego warto zabezpieczyć hasłem Twój katalog administracyjny WordPress?

Zabezpieczając hasłem swój katalog administracyjny WordPress, dodajesz dodatkową warstwę zabezpieczeń do najważniejszego punktu wejścia do twojej witryny internetowej WordPress.

Twój kokpit administratora WordPress jest centralnym punktem Twojej witryny. To tutaj publikujesz wpisy i strony, dostosowujesz swój motyw, instalujesz wtyczki WordPress i nie tylko.

Często, gdy hakerzy próbują dostać się na twoją witrynę internetową, robią to za pośrednictwem ekranu wp-admin przy użyciu ataku siłowego.

Możesz pomóc chronić twoją witrynę internetową przed potencjalnymi atakami, stosując zabezpieczenia, takie jak silne hasło i ograniczenie prób logowania.

Aby być jeszcze bardziej zabezpieczonym, możesz również zabezpieczyć hasłem katalog wp-admin. Wówczas, gdy ktoś spróbuje uzyskać dostęp do twojego obszaru administracyjnego, będzie musiał wpisz nazwę użytkownika i hasło, zanim w ogóle dotrze do strony logowania WordPress.

Mając to na uwadze, przyjrzyjmy się, jak krok po kroku zabezpieczyć hasłem twój katalog administracyjny WordPress.

Pierwsza metoda jest zalecana dla większości użytkowników i możesz skorzystać z poniższych szybkich odnośników, aby przejść bezpośrednio do metody, której chcesz użyć:

Film instruktażowy

Subscribe to WPBeginner

Jeśli wolisz pisemne instrukcje, czytaj dalej.

Metoda 1: Zabezpieczony hasłem wp-admin przy użyciu funkcji prywatności katalogów (zalecane)

Najprostszym sposobem na zabezpieczenie hasłem katalogu administracyjnego WordPress jest użycie aplikacji Directory Privacy dostawcy hostingu WordPress.

Najpierw należy logować się do kokpitu konta hostingowego i kliknąć opcję „Prywatność katalogów” w sekcji Pliki w kokpicie Twojej witryny internetowej.

Click on the Directory Privacy option in the Files section

Uwaga: Większość hostów internetowych korzystających z cPanel, takich jak Bluehost, będzie miała podobne kroki. Jednak twój kokpit może się nieco różnić od naszych zrzutów ekranu, w zależności od dostawcy hostingu.

Spowoduje to wyświetlenie ekranu z listą różnych katalogów na twoim serwerze. Musisz znaleźć katalog zawierający pliki twojej witryny internetowej.

W przypadku większości właścicieli witryn internetowych można to znaleźć, klikając katalog „public_html”.

Click public_html

Spowoduje to wyświetlenie wszystkich plików witryny internetowej zainstalowanych na twoim serwerze.

Następnie należy kliknąć katalog z nazwą domeny twojej witryny internetowej.

Click domain name folder

W tym folderze zobaczysz katalog wp-admin.

Zamiast klikać nazwę katalogu, należy kliknąć przycisk „Edytuj” obok tego katalogu.

Click edit wp-admin folder

Spowoduje to wyświetlenie ekranu, na którym można włączyć zabezpieczenie hasłem.

Wystarczy zaznaczyć pole „Zabezpiecz ten katalog hasłem”. Jeśli chcesz, możesz również nadać twojemu katalogowi nazwę, taką jak „Obszar administracyjny”, aby ułatwić zapamiętanie.

Check password protect directory box

Gdy to zrobisz, musisz kliknąć przycisk „Zapisz”.

Spowoduje to przejście do strony, na której pojawi się komunikat z potwierdzeniem.

Confirmation message click back button

Teraz musisz kliknąć przycisk „Wróć”, a zostaniesz przeniesiony do ekranu, na którym możesz utworzyć użytkownika, który będzie mógł uzyskać dostęp do tego katalogu.

Zostaniesz poproszony o wpisz nazwy użytkownika i hasła, a następnie potwierdź hasło. Pamiętaj, aby zapisać swoją nazwę użytkownika i hasło w bezpiecznym miejscu, takim jak aplikacja do zarządzania hasłami.

Create a User

Upewnij się, że kliknąłeś przycisk „Zapisz”, gdy to zrobiłeś.

Teraz, gdy ktoś spróbuje uzyskać dostęp do twojego katalogu wp-admin, zostanie poproszony o wpisz nazwy użytkownika i hasła, które utworzyłeś powyżej.

Password protect WordPress admin example

Metoda 2: Zabezpieczony hasłem wp-admin przy użyciu kodu

Możesz również ręcznie zabezpieczyć hasłem twój katalog administracyjny WordPress. Aby to zrobić, musisz utworzyć dwa pliki o nazwach .htpasswd i .htaccess.

Uwaga: Dodawanie jakiegokolwiek kodu do twojej witryny WordPress może być niebezpieczne. Nawet mały błąd może spowodować poważne błędy na twojej witrynie internetowej. Zalecamy tę metodę tylko zaawansowanym użytkownikom.

Tworzenie pliku .htaccess

Najpierw otwórz twój preferowany edytor tekstu i nazwij nowy plik .htaccess.

Następnie należy skopiować poniższy fragment kodu i dodać go do pliku:

AuthName "Admins Only"
AuthUserFile /home/user/public_html/example.com/wp-admin/.htpasswd
AuthGroupFile /dev/null
AuthType basic
require user yourusername

Upewnij się, że zmieniłeś ścieżkę „AuthUserFile” na lokalizację, do której prześlesz plik .htpasswd i zmieniłeś „yourusername” na nazwę użytkownika, której chcesz używać do logowania się.

Nie zapomnij zapisać pliku po zakończeniu.

Tworzenie pliku .htpasswd

Gdy już to zrobisz, musisz utworzyć plik .htpasswd.

Aby to zrobić, otwórz edytor tekstu i utwórz plik o nazwie .htpasswd. Plik ten będzie zawierał twoją nazwę użytkownika wraz z hasłem w zaszyfrowanym formacie.

Najprostszym sposobem na wygenerowanie zaszyfrowanego hasła jest użycie generatora htpasswd.

Po prostu wpisz swoją nazwę użytkownika i hasło, wybierz format szyfrowania i kliknij przycisk „Utwórz plik .htpasswd”.

Create htpasswd file

Generator htpasswd wyświetli linię tekstu, którą należy wkleić do twojego pliku .htpasswd. Upewnij się, że zapisałeś plik po wykonaniu tej czynności.

Przesyłanie .htaccess i .htpasswd do katalogu wp-admin

Ostatnim krokiem jest przesłanie obu utworzonych plików do katalogu wp-admin twojej witryny internetowej.

Będziesz musiał połączyć się ze swoim kontem hostingowym WordPress za pomocą klienta FTP lub narzędzia do zarządzania plikami online dostarczonego przez dostawcę hostingu. Aby uzyskać więcej informacji, zapoznaj się z naszym przewodnikiem dla początkujących na temat korzystania z FTP do przesyłania plików do WordPress.

W tym poradniku użyjemy programu FileZilla, ponieważ jest on darmowy i działa zarówno na komputerach Mac, jak i Windows.

Po połączeniu się ze swoją witryną, w lewym oknie zobaczysz pliki na twoim komputerze, a w prawym pliki na twojej witrynie internetowej. Po lewej stronie musisz przejść do lokalizacji, w której zapisałeś pliki .htaccess i .htpasswd.

Następnie, po prawej stronie, musisz przejść do katalogu wp-admin dla witryny internetowej, którą chcesz zabezpieczyć. Większość użytkowników będzie musiała dwukrotnie kliknąć folder public_html, następnie katalog z nazwą swojej domeny, a następnie katalog wp-admin.

Teraz możesz wybrać dwa pliki po lewej stronie i kliknąć „Prześlij” z menu po kliknięciu prawym przyciskiem myszy lub po prostu przeciągnąć pliki do lewego okna.

Uploading the Files to Your Website's wp-admin Directory

Teraz twój katalog „wp-admin” będzie zabezpieczony hasłem.

Rozwiązywanie problemów z zabezpieczeniem hasłem wp-admin

W zależności od tego, jak skonfigurowany jest twój serwer i witryna internetowa, istnieje szansa, że napotkasz błędy WordPress. Błędy te można naprawić poprzez staranne dodanie kodu do twojego pliku .htaccess.

Uwaga: Jest to plik .htaccess znajdujący się w twoim głównym katalogu witryny internetowej, a nie ten, który przesłałeś do katalogu „wp-admin”. Jeśli masz problemy z jego znalezieniem, zapoznaj się z naszym przewodnikiem na temat tego, dlaczego nie możesz znaleźć .htaccess i jak go zlokalizować.

Poprawki do błędu niedziałającego Ajaxa

Jednym z najczęstszych błędów jest to, że funkcjonalność Ajax może przestać działać na front-endzie twojej witryny. Jeśli masz wtyczki WordPress, które wymagają Ajax, takie jak wyszukiwanie na żywo Ajax lub formularze kontaktowe Ajax, to powiadomienie, że te wtyczki nie będą już działać.

Aby to naprawić, wystarczy dodać następujący kod do pliku .htaccess, który znajduje się w twoim katalogu wp-admin:

<Files admin-ajax.php>
    Order allow,deny
    Allow from all
    Satisfy any 
</Files>

Poprawka błędu 404 i zbyt wielu przekierowań

Dwa inne błędy, które możesz napotkać, to błąd 404 i błąd zbyt wielu przekierowań.

Najprostszym sposobem na ich poprawienie jest otwarcie głównego pliku .htaccess znajdującego się w katalogu twojej witryny internetowej i dodanie następującej linii kodu przed regułami WordPress:

ErrorDocument 401 default

Bonus: Najlepsze przewodniki WordPress dotyczące zabezpieczeń wp-admin

Teraz, gdy już wiesz, jak zabezpieczyć hasłem katalog wp-admin, możesz zapoznać się z tymi przewodnikami na temat zwiększania bezpieczeństwa obszaru administracyjnego:

Mamy nadzieję, że ten artykuł pomógł ci dowiedzieć się, jak zabezpieczyć hasłem twój katalog administracyjny WordPress (wp-admin). Zachęcamy również do zapoznania się z naszym przewodnikiem na temat tego, jak uzyskać bezpłatną domenę e-mail oraz z naszą listą najlepszych usług e-mail marketingu dla małych firm.

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.

Ujawnienie: Nasze treści są wspierane przez czytelników. Oznacza to, że jeśli klikniesz na niektóre z naszych linków, możemy otrzymać prowizję. Zobacz jak WPBeginner jest finansowany, dlaczego to ma znaczenie i jak możesz nas wspierać. Oto nasz proces redakcyjny.

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.

Najlepszy zestaw narzędzi WordPress

Uzyskaj BEZPŁATNY dostęp do naszego zestawu narzędzi - zbiór produktów i zasobów związanych z WordPressem, które każdy profesjonalista powinien mieć!

Reader Interactions

204 komentarzeZostaw odpowiedź

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

    Thanks. I found it helpful.
    I want to ask if the methods are all offering the same level of security, I would prefer and recommend to stick to the first method as it seems easy and straight forward.

    Or is there any one that is better than the other ??

    • WPBeginner Support says

      These are different methods to achieve the same result so it would depend on your preference for which one you would use.

      Administrator

  3. Salman says

    I have changed my login URL using the „WPS Hide Login” plugin. Lets say the previous URL ended in wp-admin/ and the new URL ends in hidden/ now how can I password protect this new URL?

    • WPBeginner Support says

      It would depend on what method you are using and how you changed the URL, as long as there is a file/folder in the new location you should be able to select that folder or change the path on line 2 of the htaccess method :)

      Administrator

    • Jiří Vaněk says

      WPShide doesn’t create a new folder, I use that too. The wp-admin folder is still on the server and functional. So if you use WPSHide, secure the wp-admin folder exactly the same.

  4. Jiří Vaněk says

    A good practice is also to rename the WordPress administration URL and choose a different administrator username than 'admin.’ Changing the URL makes it harder for attackers to locate the administration, and not using 'admin’ as the administrator reduces the risk of a successful brute force attack.

    • WPBeginner Support says

      Having a username other than admin is definitely recommended but for changing the wp-admin url is not always recommended as that can cause trouble with some plugins as well as make troubleshooting more difficult.

      Administrator

  5. Umer Yaseen says

    What if someone accesses our WordPress admin directory by entering mywebsite.com/wp-login.php instead of mywebsite.com/wp-admin. This method only protects wp-admin and not protects wp-login.php. So how it is useful?

    • WPBeginner Support says

      We’ll see if we can add a method for that type of server when we update this article :)

      Administrator

  6. Rajah says

    The first method through cPanel worked like a charm. However, when I logout again from WP and login again it doesn’t ask again for the directory password. Is it meant to ask only once?

    • WPBeginner Support says

      Your cookies/cache will remember the login information. Normally the next time you start up your computer it will require you to log in again.

      Administrator

  7. Izzy says

    The „Password Protect Directories” is not on my cPanel under „securitiy”, so I tried the manual way, but it doesn’t seem to work as it doesn’t ask for login when I open wp-admin…

    • WPBeginner Support says

      If you reach out to your hosting provider they should be able to assist and take a look if there’s any reason it wouldn’t be working.

      Administrator

  8. Ahsan Ali says

    Thanks for your efforts!
    I used cpanel method it works fine but the problem is that the password prompt appearing on every page of my website!

    What i have to do so that it appear only at wp-admin page?

    • WPBeginner Support says

      It sounds like you may have password protected your public_html folder instead of the wp-admin folder. You would want to remove the current protection and attempt to set it up again

      Administrator

    • WPBeginner Support says

      That would be where your WordPress folders are, you could either use FTP or your host’s file manager if they have one to get to your WordPress files.

      Administrator

  9. CHHRIS says

    Please this settings works fine for me, but my problem is that am using woocommerce and yith woocoomerce my account page, so when ever users login to their my-account area they are often prompted to put the login details for my protected admin, how can i fix this?

    • WPBeginner Support says

      For that, you would want to remove this protection unless you wanted to give each user a login for the httpassword

      Administrator

    • WPBeginner Support says

      It would depend on the specific error you are running into when trying to get to your admin area for how to solve the problem

      Administrator

  10. Rahul Yogi says

    Hy buddy, i had tried cpanel method which doesnt work for me but manual method work as shown above.

    But i have one problem after going example.com/admin, i have to enter directory username and password but after after entering nothing happens means it does not redirect me to dashboard or anywhere. Just same page — shoing waiting for connection for example.com and get error too many redirect.

  11. Brian says

    Wow,

    You are a legend! Spent like 2hrs jumping from site to site to get this working… First site that mentioned the ErrorDocument 401 default. Works like a charm now

    Thanks

  12. Deb says

    Thanks so much – this is the first place I have found with all 3 bits of code that was needed – (I had the redirect problem). The code worked like a charm. I now have an extra layer of protection without adding another potentially vulnerable plugin.

    • WPBeginner Support says

      If the htaccess method is not working you could remove the code and then use the cpanel method for password protecting the directory

      Administrator

  13. Samwel says

    I followed the steps but i now can’t log in . It says „The server encountered an internal error or misconfiguration and was unable to complete your request.”

    even on refreshing the page the pop up to key in password does not re-appear help out

  14. maria hag says

    hi,

    i bought new name and i change the name of website and than save it . now i cant login to admin. it show me 404 erorr
    how can i change it
    please advise

    • WPBeginner Support says

      You would want to reach out to your hosting provider and they should be able to help you have your new domain point toward where your site is currently

      Administrator

  15. taher says

    I have activated password protection to wordpress directory via c-panel but wordfence is unable to scan my site. Due to ajax issue.

    I tried fixing it by updating my wp-admin/.htaccess file with the provided code by you but wordfence is still unable to start a scan. What do you suggest?

    • WPBeginner Support says

      You may want to ensure your caching is cleared and if that error continues, reach out to Wordfence about their plugin

      Administrator

  16. Amit Mukherjee says

    Enabling password protection of the wp-admin directory prevents me as logging in as the administrator. I get a page not found error. I cannot get to the login page. If I remove the password protection, I can login.

    What should I do. I am setting up a WordPress website for the first time.

  17. mary-anne J. says

    So how do you undo the password protect using the cPanel ..that is, I want to remove my password protection for the wp-admin directory

  18. Keri says

    I followed the instructions to add the password protection using c_panel.

    It works fine in IE 11 but doesn’t work in: Edge; Firefox; Chrome; or Opera.
    Any ideas?

      • Keri says

        I’m not sure what I missed, given that it worked in IE but not in the other browsers. I deleted the user to whom I had given access and added the same user back in and, „Voila!”, all is good.

  19. Valentin says

    > Upload this file outside your /public_html/ directory.

    Good advice—more generally: outside your DocRoot.

    > A good path would be: home/user/.htpasswds/public_html/wp-admin/passwd/

    That, however, doesn’t seem to be outside your DocRoot ;)

  20. pawan singh says

    hi syed, i followed your tutorial as i do always whenever i find a problem but i am facing this error continiously.

    ERROR –

    „401
    Unauthorized

    Proper authorization is required to access this resource!”

    1. I made htpassword file properly with user name and password.
    2. Edited main .htaccess file with proper code.
    3. Implemented this line in .htaccess file on topas first line
    ErrorDocument 401 default
    4. Add AJAX functionality code

    After doing all this i see additional popup box which need login details for wp-admin. – Success here

    But i’m not able to access my home page like example.com. popupbox appears again without calling /wp-admin. Please tell how to remove this 401 Error. I see that many bloggers asked this issue in comment section, but you didn’t reply. I hope you will soon address the problem.

    • WPBeginner Support says

      Hello Pawan,

      This could be because the password your entered is incorrect or your server couldn’t find the .htpasswds file. We will recommend you to retrace your steps to figure out what went wrong.

      Administrator

      • Robbiegod says

        I am seeing the same issue. On subpages on my site, when I have my /wp-admin/ .htaccess password protecting my site, I get the user/pass pop-up box on pages on the front end.

        The temporary solution was to just remove the htaccess file from wp-admin. Now i am trying to put it back, so I’ll see what i can come up with and post back if i figure it out.

  21. Arinze Ifeanyi says

    Thank you for this. I worked really well especially that line „ErrorDocument 401 default” that prevented it from giving 404 error. I really dont miss tweet from you. My question now is, how can someone remove the password? And again, will the password be required upon users registration via a custom registration page?

  22. Rony Ahamed says

    after using this method now when i try to go in wp-admin its says me maintenance mood ( this mode is on in my wp dashboard ) .. so how can i use it ?

  23. Adrian says

    Do you have a method using IIS? I’ll be glad if you have. I’m very new to WordPress running in IIS server.

  24. pawan says

    hi how to change my cpanel default url like „www.example.com/cpanel” to „www.example.com/customized”
    there is nothing on the internet about this topic.

  25. Edgar says

    Hi my dear friends I have a problem. I want to make double autentification on my wordpress.But there is conflict in wordpress htacsess between wp default rules and this code:

    AuthType Basic
    AuthName „Password Protected”
    AuthUserFile path/to/.htpasswd
    Require valid-user
    Satisfy All

    I get error like 500 or error „this page is wrong”, but after delating wp default rules my code work.There is some conflict between wp code and my code! Can anyone take solution!

  26. Aurangzeb says

    A very nice approach, but I also suggest to go secure with https, because no matter how protected the admin panel is, with passwords, the passwords itself are not secure if it’s not https.

  27. Daljit Singh says

    Hey guys, my issue is related to this post but it is little different too.
    I need to password protect my wp-content folder in my hosting.
    I called my godaddy hosting and they said that it is not possible.
    But i need to password protect it.
    Can someone help me out please?

  28. Akhil says

    Password Protecting WordPress Admin with Permalink „Post Name” gives error error login page( Redirect too many times). How to solve?

  29. Harmony A-E says

    Can I do this for my wp-login?

    The wp-admin is password protected and gives out a 401 if some tries to exit the pop-up (so 0 access without the 1st password).

    But my wp-login allows access to a disfigured wp-login page if someone exits out of the pop-up.

  30. Frank says

    That’s a great article.

    However, I’d like to ask you how can I track the who visits the page (IP, etc) even though if they don’t type any username or password or type wrong ones. I can’t seem to find a way to do that.

    Please let me know.
    Thanks!

  31. Deivamoorthy says

    Thanks for this article. It is really helped me lot save the login form anonymous person. But, i have an issue on my site. Whenever the user visits and entering to the single post page it asks the user enter the username password, Even though they have didn’t accessed the wp -admin. it happens only in Mozilla browser. How to solve this?

  32. Toan says

    I has finished setting protect password for wp-admin folder. But i can not registered new account for guest. Because it apperance pop-up login require username/password.

  33. paras arora says

    sir actually i have changed my admin directory from example.com/wp-admin to example.com/abcde …how to password protect it now

  34. Sarah says

    Thanks for this valuable info.I have question I want to setup limit login Attempts if users fails 1st time then try after 24 hrs latter how to I make this on cpanel?

  35. RJ says

    Hi there I do password protect my wp-admin directory and I did add that code to my htaccess …but…it is still asking for authorization.

    Any suggestions?

  36. dipesh says

    i dont ve set password for wp-admin folder but still it shows authorization dialog .
    how to solve the issue,

Zostaw odpowiedź

Dziękujemy za pozostawienie komentarza. Pamiętaj, że wszystkie komentarze są moderowane zgodnie z naszymi polityka komentarzy, a Twój adres e-mail NIE zostanie opublikowany. NIE używaj słów kluczowych w polu nazwy. Przeprowadźmy osobistą i konstruktywną rozmowę.