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 limitare l’accesso all’amministrazione di WordPress in base all’indirizzo IP

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 limitare l’accesso all’area di amministrazione di WordPress per motivi di sicurezza?

Se il team è piccolo, una buona soluzione è quella di limitare l’accesso solo agli indirizzi IP utilizzati dai membri del team.

In questo articolo vi mostreremo come limitare l’accesso all’amministrazione di WordPress per indirizzo IP, passo dopo passo.

How to Restrict WordPress Admin Access by IP Address

Perché limitare l’accesso dell’amministratore di WordPress in base all’indirizzo IP?

Se gestite un sito web con WordPress, dovete prendere sul serio la sicurezza del vostro sito. Sebbene il software di base di WordPress sia molto sicuro, potete fare di più per proteggervi dagli hacker e dagli attacchi brute force.

Gli hacker possono far cadere il vostro sito web, oltre a danneggiare le vostre entrate e la vostra reputazione. Possono rubare dati o addirittura distribuire malware ai visitatori del vostro sito web e far sì che il vostro dominio venga aggiunto in blacklist da Google e altri.

Un modo intelligente per bloccare gli hacker e migliorare la sicurezza di WordPress è proteggere l’area di amministrazione di WordPress da accessi non autorizzati.

Se solo voi o alcuni utenti fidati avete bisogno di accedere all’area di amministrazione, un buon modo per farlo è limitare l’accesso a wp-admin e alla pagina di accesso a WordPress agli indirizzi IP del vostro team.

Ogni membro del team si collegherà al vostro sito WordPress utilizzando un indirizzo IP specifico per ogni sede. Se bloccate l’accesso a tutti gli altri indirizzi IP, un hacker non sarà in grado di accedere al vostro sito web anche se ha scoperto nome utente e password.

Al contrario, verrà visualizzato il messaggio di errore: ‘Vietato. Non hai i permessi per accedere a questa risorsa”.

Vediamo come limitare l’accesso all’amministrazione di WordPress in base all’indirizzo IP.

Come limitare l’accesso all’amministrazione di WordPress in base all’indirizzo IP

La prima cosa da fare è stilare un elenco degli indirizzi IP utilizzati da tutti coloro che devono accedere al vostro sito web WordPress. Se qualcuno lavora da più sedi, dovrete raccogliere gli indirizzi IP di ciascuno.

Possono imparare il loro indirizzo IP visitando un sito come SupportAlly.

Una volta stilato l’elenco, è necessario modificare un file sul sito web. Dovrete utilizzare un client FTP o l’applicazione di gestione dei file del vostro fornitore di hosting. Se non avete mai usato l’FTP, potete consultare la nostra guida su come usare l’FTP per l’uploader dei file su WordPress.

È necessario utilizzare il software per navigare nella cartella /wp-admin/ del sito web. Una volta lì, si deve cercare il file .htaccess. Si tratta di un file nascosto, quindi se non riuscite a vederlo, potreste dover abilitare l’opzione mostra file nascosti nel vostro software.

Navigate to wp-admin and Locate .htaccess

Se il file non esiste nella cartella, occorre crearne uno nuovo e salvarlo con il nome .htaccess nella cartella /wp-admin/.

Attenzione: Non modificate il file .htaccess principale, altrimenti bloccherete i visitatori dal frontend del vostro sito web! Assicuratevi di modificare /wp-admin/.htaccess.

Per prima cosa è necessario scaricare una copia del file sul computer come backup. Una volta fatto ciò, è necessario modificare .htaccess e incollare il seguente codice:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "WordPress Admin Access Control"
AuthType Basic
<LIMIT GET>
order deny,allow
deny from all
# whitelist Syed's IP address
allow from xx.xx.xx.xxx
# whitelist David's IP address
allow from xx.xx.xx.xxx
# whitelist Amanda's IP address
allow from xx.xx.xx.xxx
# whitelist Muhammad's IP address
allow from xx.xx.xx.xxx
# whitelist Work IP address
allow from xx.xx.xx.xxx
</LIMIT>

Modificate il file in corrispondenza dei nomi dei membri del vostro team e incollate gli indirizzi IP raccolti in precedenza per sostituirli a quelli di xx.xx.xx.xxx.

Una volta salvato il file, solo questi indirizzi IP potranno accedere all’amministrazione di WordPress.

Ricordate che se il vostro indirizzo IP cambia o cercate di accedere al vostro sito web da una nuova posizione, sarete bloccati dall’area di amministrazione di WordPress. Dovrete aggiungere il vostro nuovo indirizzo IP al file /wp-admin/.htaccess.

Speriamo che questo tutorial vi abbia aiutato a capire come limitare l’accesso all’amministrazione di WordPress in base all’indirizzo IP. Potreste anche consultare il nostro tutorial su WordPress su come ottenere un certificato SSL gratuito per il vostro sito web o dare un’occhiata al nostro elenco dei plugin indispensabili per far crescere il vostro sito.

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

43 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!

    • WPBeginner Support says

      You would need to have your FTP or file manager show hidden files if you do not see it.

      Admin

    • WPBeginner Support says

      There are multiple methods to find your IP, one of the simple ones would be to use a site like supportally.com

      Admin

  2. Rostyslav says

    After this line, you must put a condition for permission to allow php files to prevent conflicts:

    allow from all

  3. Solace says

    I tried the .htaccess password protection method.

    It works, but I tried it on a site with Woocommerce, but then my customers weren’t able to log in.

    Just saying that because it seems no one has mentioned that it doesn’t work with sites that need customers to log in !

  4. Miguel says

    Hello, thank you for the tutorial. Unfortunately, I have not been able to make this .htaccess file to work correctly because it is denying access to the only IP address I included, my own… I am certain I copied your code exactly and I typed my IP correctly. The .htaccess file was saved under: /wp-admin/.htaccess

    Am I missing something? Thanks

  5. Emaan Ali says

    Hi Guys,

    I have blocked the wp-admin with .htaccess as mentioned in this article. But i am having one problem that my admin-ajax file is also being restricted on public site.

    My wordpress theme uses much of admin ajax functionality and that I have put the IP limitation access on wp-admin folder so its not accessible for all IP’s.

    Does anyone find the solution for this ? If so please share .

    Thanks in advance
    Emaan

  6. Len says

    Hi, This seems really a helpful one. Maybe you could help me. Instead of whitelisting an IP can we allow access for specific countries in .htaccess file? Hoping you can help me. Thank you very much.

  7. Scotty says

    Hi, This does work. I checked and am “forbidden” to login on any other computer. I can’t even see the login panel. However, I am still getting about 24 failed log in attempts per day from all different IP addresses. Any ideas how there getting around this? It’s some kind of brute force attack? Thanks, Scott.

  8. Sehrish says

    And how to allow access to only wordpress adminitrator ?What code i will write without any ip ? I just need to know a generic function that get admin related info.Becuse i have to restrict my plugin uploads from other user.And Whoever using this plugin i have to get its admin info to restrict contents from other and allow only to admin of website.

  9. Kim says

    I tried this (after previously successfully password protecting my wp-admin directory and fixing the redirect error per your other article), but then I get a pop-up asking for a user name and password for the “WordPress Admin Access Control”. What user name and password am I supposed to be using for this new pop-up? Neither the wordpress admin logon nor the wp-admin directory logon work for it.
    Thanks!

    • Kim says

      Oh, I believe I figured out the problem; seems to work as long as I make sure to have the added code at the very beginning.

  10. Jordyn says

    I have a big problem :(

    I did what you said about creating the .htaccess and putting in the code snippet. It didn’t work so I deleted the .htaccess file and now I can’t login to my dashboard! It’s just a white screen :( Please help!!!

    Thanks

      • Jordyn says

        All I did was create the file in my wp-admin folder and when it didn’t work I deleted it from the wp-admin folder. I’m not sure what happened but, after a crazy rabbit trail and many shots in the dark, I was able to correct the problem by adding to the top of my login.php file. I still don’t know what went wrong or why what I did fixed it…. but at least its fixed. I may try this again when I’m feeling brave.

  11. Raheem Khan says

    Hi WPB, I don’t think it will be working in Pakistan because every time we reset or turn of our DSL modem so the IP address automatically changes. if any other tip please reply me.
    Thanks

  12. andrew says

    hi, how to make .htaccess with dynamic ip (non static ip)
    my ip is always change xxx.xxx.xxx.12 xxx.xxx.xxx.453 xxx.xxx.xxx.076

    please help…

      • Joe says

        You can harden your wordpress install via .htaccess whitelisting even if you have a dynamic IP address. You can whitelist a range of IP addresses using a /24 or /16 range. While this allows more access than if you always knew the IP you wanted to allow, it still prohibits access from almost the entire internet.

        Just add /24 to the end of the allow from line to allow the whole class C subnet (256 IPs), or add /16 to allow the whole 65,536 range. i.e.

        allow from xxx.xxx.xxx.0/24

        will allow access to IP addresses from xxx.xxx.xxx.0 – xxx.xxx.xxx.255. and

        allow from xxx.xxx.0.0/16

        will allow access from IP addresses from xxx.xxx.0.0 – xxx.xxx.255.255

  13. Kyle says

    You say not to do the root site’s .htaccess file…why is that? Because you just want to limit access to the /wp-admin folder?

    So…if I wanted to have a WordPress site hosted externally but used as an internal company resource so that only people using IPs of our company could access it…if I edited the root folder’s .htaccess folder to only allow IPs from our domain…that would work the same way your /wp-admin fix is, but for the entire site, correct?

    • Editorial Staff says

      Yes Kyle, the reason why we said do not put this code in the root file because then it will limit your site access to only these IP as well. But if you are trying to make a site just for your company’s staff can access it only from work, then you would want to put the .htaccess file in the root folder.

      Admin

    • Alim Bolar says

      Can I limit access based on other criterias? Like I need only my laptop to access a particular folder.. I could access it from anywhere so it would be difficult to specify an IP as my internet access would be based on DHCP. Is there a unique identifier for every machine or something like that that can be used as a criteria?

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.