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 proteggere con password la directory amministrativa di WordPress (wp-admin)

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 imparare a proteggere con una password la directory di amministrazione di WordPress?

L’aggiunta di un ulteriore livello di protezione con password alla directory di amministrazione di WordPress può essere un ottimo modo per migliorare la sicurezza di WordPress.

In questo articolo scoprirete come proteggere con una password la vostra directory wp-admin in modo semplice.

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

Perché proteggere con password la directory amministrativa di WordPress?

Proteggendo la directory di amministrazione di WordPress con una password, aggiungete un ulteriore livello di sicurezza al punto di ingresso più importante del vostro sito WordPress.

La dashboard di amministrazione di WordPress è l’hub centrale del vostro sito. È qui che pubblicherete post e pagine, personalizzerete il vostro tema, installerete i plugin di WordPress e molto altro ancora.

Spesso, quando gli hacker cercano di entrare nel vostro sito web, lo fanno attraverso la schermata wp-admin utilizzando un attacco di forza bruta.

Potete contribuire a proteggere il vostro sito web da potenziali attacchi utilizzando misure di sicurezza come una password forte e limitando i tentativi di accesso.

Per essere ancora più sicuri, potete anche proteggere con una password la directory wp-admin. In questo modo, quando qualcuno tenta di accedere alla vostra area di amministrazione, dovrà inserire un nome utente e una password prima di arrivare alla pagina di login di WordPress.

Detto questo, vediamo come proteggere con una password la directory di amministrazione di WordPress, passo dopo passo.

Il primo metodo è consigliato per la maggior parte degli utenti e potete utilizzare i collegamenti rapidi qui sotto per passare direttamente al metodo che desiderate utilizzare:

Video tutorial

Subscribe to WPBeginner

Se preferite le istruzioni scritte, continuate a leggere.

Metodo 1: Proteggere wp-admin con password usando Directory Privacy (consigliato)

Il modo più semplice per proteggere con una password la directory di amministrazione di WordPress è utilizzare l’applicazione Directory Privacy del vostro provider di hosting WordPress.

Per prima cosa, dovete accedere al cruscotto del vostro account di hosting e fare clic sull’opzione “Directory Privacy” nella sezione File del cruscotto del vostro sito web.

Click on the Directory Privacy option in the Files section

Nota: la maggior parte degli hosting web che utilizzano cPanel, come Bluehost, prevedono passaggi simili. Tuttavia, il vostro cruscotto potrebbe essere leggermente diverso dalle nostre schermate, a seconda del vostro provider di hosting.

Si accede così a una schermata che elenca tutte le diverse directory presenti sul server. È necessario trovare la cartella che contiene i file del sito web.

Per la maggior parte dei proprietari di siti web, è possibile trovarla facendo clic sulla cartella “public_html”.

Click public_html

In questo modo vengono visualizzati tutti i file del sito web installati sul server.

Successivamente, dovrete fare clic sulla cartella con il nome di dominio del vostro sito web.

Click domain name folder

In questa cartella, si vedrà una cartella wp-admin.

Invece di fare clic sul nome della cartella, è necessario fare clic sul pulsante “Modifica” accanto alla cartella.

Click edit wp-admin folder

Si accede così a una schermata in cui è possibile attivare la protezione con password.

È sufficiente selezionare la casella “Proteggi questa directory con password”. Se si vuole, si può anche assegnare alla directory un nome, come “Area amministrativa”, per aiutarsi a ricordare.

Check password protect directory box

Una volta fatto ciò, è necessario fare clic sul pulsante “Salva”.

In questo modo si accede a una pagina in cui viene visualizzato il messaggio di conferma.

Confirmation message click back button

A questo punto, è necessario fare clic sul pulsante “Torna indietro” e si accede a una schermata in cui è possibile creare un utente in grado di accedere a questa directory.

Vi verrà chiesto di inserire un nome utente e una password e di confermare la password. Assicurarsi di annotare il nome utente e la password in un luogo sicuro, ad esempio in un’applicazione di gestione delle password.

Create a User

Assicuratevi di fare clic sul pulsante “Salva” al termine di questa operazione.

Ora, quando qualcuno cercherà di accedere alla directory wp-admin, gli verrà richiesto di inserire il nome utente e la password creati in precedenza.

Password protect WordPress admin example

Metodo 2: proteggere con password wp-admin usando il codice

È anche possibile proteggere manualmente la directory di amministrazione di WordPress con una password. Per farlo, dovrete creare due file chiamati .htpasswd e .htaccess.

Nota: l ‘aggiunta di codice al vostro sito WordPress può essere pericolosa. Anche un piccolo errore può causare gravi errori sul vostro sito web. Consigliamo questo metodo solo agli utenti esperti.

Creazione del file .htaccess

Per prima cosa, aprite il vostro editor di testo preferito e nominate il nuovo file .htaccess.

Successivamente, è necessario copiare il seguente frammento di codice e aggiungerlo al file:

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

Assicuratevi di cambiare il percorso ‘AuthUserFile’ con il percorso in cui caricherete il file .htpasswd e cambiate ‘yourusername’ con il nome utente che volete usare per accedere.

Non dimenticate di salvare il file una volta terminato.

Creazione del file .htpasswd

Una volta fatto questo, è necessario creare un file .htpasswd.

Per farlo, aprite un editor di testo e create un file chiamato .htpasswd. Questo file elencherà il vostro nome utente e la vostra password in un formato criptato.

Il modo più semplice per generare la password criptata è un generatore di htpasswd.

È sufficiente inserire il nome utente e la password, selezionare il formato di crittografia e fare clic sul pulsante “Crea file .htpasswd”.

Create htpasswd file

Il generatore di htpasswd visualizzerà una riga di testo che dovrete incollare nel vostro file .htpasswd. Assicuratevi di salvare il file una volta fatto.

Caricamento di .htaccess e .htpasswd nella directory wp-admin

L’ultimo passo consiste nel caricare entrambi i file creati nella cartella wp-admin del vostro sito web.

Dovrete collegarvi al vostro account di hosting WordPress utilizzando un client FTP o lo strumento di gestione dei file online fornito dal vostro provider di hosting. Per maggiori dettagli, consultate la nostra guida per principianti su come usare l’FTP per caricare file su WordPress.

Per questa esercitazione utilizzeremo FileZilla perché è gratuito e funziona sia su Mac che su Windows.

Dopo essersi collegati al sito web, si vedranno i file sul computer nella finestra di sinistra e i file sul sito web nella finestra di destra. A sinistra, è necessario navigare nella posizione in cui sono stati salvati i file .htaccess e .htpasswd.

Quindi, sulla destra, è necessario andare alla cartella wp-admin del sito web che si desidera proteggere. La maggior parte degli utenti dovrà fare doppio clic sulla cartella public_html, poi sulla cartella con il proprio nome di dominio e infine sulla cartella wp-admin.

A questo punto, è possibile selezionare i due file a sinistra e fare clic su “Carica” dal menu del tasto destro del mouse o semplicemente trascinare i file nella finestra di sinistra.

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

Ora la cartella ‘wp-admin’ sarà protetta da password.

Risoluzione dei problemi relativi alla protezione con password di wp-admin

A seconda di come sono impostati il vostro server e il vostro sito web, è possibile che vi imbattiate in errori di WordPress. Questi errori possono essere risolti aggiungendo attentamente del codice al file .htaccess.

Nota: questo è il file .htaccess che si trova nella cartella principale del sito web, non quello caricato nella cartella ‘wp-admin’. Se avete problemi a trovarlo, consultate la nostra guida sul perché non riuscite a trovare .htaccess e su come individuarlo.

Correzione dell’errore Ajax non funzionante

Uno degli errori più comuni è che la funzionalità Ajax può smettere di funzionare sul front-end del vostro sito. Se disponete di plugin WordPress che richiedono Ajax, come la ricerca live Ajax o i moduli di contatto Ajax, noterete che questi plugin non funzionano più.

Per risolvere questo problema, basta aggiungere il seguente codice al file .htaccess che si trova nella cartella wp-admin:

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

Correzione dell’errore 404 e dei troppi reindirizzamenti

Altri due errori in cui ci si può imbattere sono l’errore 404 e l’errore di troppi reindirizzamenti.

Il modo più semplice per risolverli è aprire il file .htaccess principale nella directory del sito web e aggiungere la seguente riga di codice prima delle regole di WordPress:

ErrorDocument 401 default

Bonus: Le migliori guide di WordPress per la sicurezza di wp-admin

Ora che sapete come proteggere con una password la vostra directory wp-admin, vi consigliamo di consultare queste guide per rendere più sicura la vostra area di amministrazione:

Speriamo che questo articolo vi abbia aiutato a capire come proteggere con una password la vostra directory di amministrazione di WordPress (wp-admin). Vi consigliamo anche di consultare la nostra guida su come ottenere un dominio e-mail gratuito e la nostra selezione dei migliori servizi di email marketing per le piccole imprese.

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

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

      Admin

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

      Admin

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

      Admin

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

      Admin

  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.

      Admin

  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.

      Admin

  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

      Admin

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

      Admin

  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

      Admin

    • 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

      Admin

  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.

  13. Garry says

    All I get after adding the above code in a .htacess file on /wp-admin folder is 500 internal server error.

    • 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

      Admin

  14. Colleen says

    I did this, followed the link for the error message and for some reason I don’t have a .htaccess file!

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

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

      Admin

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

      Admin

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

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

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

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

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

      Admin

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

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

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

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

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

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

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

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

  30. Akhil says

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

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

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

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

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

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

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

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

  38. dipesh says

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

      • Gaurav Agrawal says

        Hi, I am also facing the same problem. May I know what are the changes that have to be done in server configuration?

        Please let me know as soon as possible.

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.