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

Como restringir o acesso do administrador do WordPress por endereço IP

Nota editorial: Ganhamos uma comissão de links de parceiros no WPBeginner. As comissões não afetam as opiniões ou avaliações de nossos editores. Saiba mais sobre Processo editorial.

Deseja restringir o acesso à área de administração do WordPress por motivos de segurança?

Se você tiver uma equipe pequena, uma boa solução é restringir o acesso apenas aos endereços IP usados pelos membros da equipe.

Neste artigo, mostraremos como restringir o acesso do administrador do WordPress por endereço IP, passo a passo.

How to Restrict WordPress Admin Access by IP Address

Por que restringir o acesso do administrador do WordPress por endereço IP?

Se você estiver administrando um site WordPress, precisará levar a segurança do seu site a sério. Embora o software principal do WordPress seja muito seguro, há mais coisas que você pode fazer para se proteger de hackers e ataques de força bruta.

Os hackers podem derrubar seu site, além de prejudicar sua receita e reputação. Eles podem roubar dados ou até mesmo distribuir malware para os visitantes do seu site e colocar seu domínio na lista negra do Google e de outros.

Uma maneira inteligente de bloquear hackers e melhorar a segurança do WordPress é proteger sua área de administração do WordPress contra acesso não autorizado.

Se apenas você ou alguns usuários confiáveis precisarem acessar a área de administração, uma boa maneira de fazer isso é limitar o acesso ao wp-admin e à página de login do WordPress aos endereços IP da sua equipe.

Cada membro da equipe se conectará ao seu site WordPress usando um endereço IP específico para cada local. Se você bloquear o acesso a todos os outros endereços IP, um hacker não conseguirá obter acesso ao seu site, mesmo que tenha descoberto seu nome de usuário e senha.

Em vez disso, eles verão a mensagem de erro: ‘Proibido. Você não tem permissão para acessar este recurso”.

Vamos dar uma olhada em como restringir o acesso do administrador do WordPress por endereço IP.

Como restringir o acesso do administrador do WordPress por endereço IP

A primeira coisa que você precisa fazer é uma lista dos endereços IP usados por todas as pessoas que precisam fazer login no seu site WordPress. Se alguém trabalhar em vários locais, você precisará coletar o endereço IP de cada um deles.

Eles podem saber seu endereço IP visitando um site como o SupportAlly.

Depois de fazer sua lista, você precisará editar um arquivo em seu website. Você terá de usar um cliente FTP ou o aplicativo gerenciador de arquivos do seu provedor de hospedagem. Se você nunca usou FTP antes, consulte nosso guia sobre como usar o FTP para fazer upload de arquivos no WordPress.

Você precisará usar o software para navegar até a pasta /wp-admin/ do seu site. Uma vez lá, você deve procurar o arquivo .htaccess. Esse é um arquivo oculto, portanto, se não puder vê-lo, talvez seja necessário ativar a opção mostrar arquivos ocultos no software.

Navigate to wp-admin and Locate .htaccess

Se esse arquivo não existir na pasta, você deverá criar um novo arquivo e salvá-lo com o nome .htaccess na pasta /wp-admin/.

Aviso: Não edite o arquivo raiz .htaccess, ou você bloqueará os visitantes do front-end do seu site! Certifique-se de que esteja editando /wp-admin/.htaccess.

Primeiro, você deve fazer o download de uma cópia do arquivo para o seu computador como backup. Depois de fazer isso, você precisará editar o arquivo .htaccess e colar o seguinte código:

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>

Vá em frente e edite o arquivo para que corresponda aos nomes dos membros da sua própria equipe e, em seguida, cole os endereços IP que você coletou anteriormente para substituir onde está escrito xx.xx.xx.xxx.

Depois de salvar o arquivo, somente esses endereços IP poderão acessar o administrador do WordPress.

Lembre-se de que, se o seu endereço IP mudar ou se você tentar acessar o site de um novo local, a área de administração do WordPress será bloqueada. Você precisará adicionar seu novo endereço IP ao arquivo /wp-admin/.htaccess.

Esperamos que este tutorial tenha ajudado você a aprender como restringir o acesso do administrador do WordPress por endereço IP. Talvez você também queira ver nosso tutorial do WordPress sobre como obter um certificado SSL gratuito para seu site ou conferir nossa lista de plug-ins obrigatórios para expandir seu site.

Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.

Divulgação: Nosso conteúdo é apoiado pelo leitor. Isso significa que, se você clicar em alguns de nossos links, poderemos receber uma comissão. Veja como o WPBeginner é financiado, por que isso é importante e como você pode nos apoiar. Aqui está nosso processo editorial.

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.

O kit de ferramentas definitivo WordPress

Obtenha acesso GRATUITO ao nosso kit de ferramentas - uma coleção de produtos e recursos relacionados ao WordPress que todo profissional deve ter!

Reader Interactions

43 ComentáriosDeixe uma resposta

  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

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

      Administrador

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

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

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

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

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

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

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

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

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

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

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

      Administrador

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

Deixe uma resposta

Obrigado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossos política de comentários, e seu endereço de e-mail NÃO será publicado. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.