How to Restrict Access to wp-login.php by IP Address

Oct 3, 2011

If you are looking to improve the security of your WordPress website, you might consider restricting access to the wp-login.php login file. A great way to do this is thru the use of an .htaccess file.
Sample code is below. This code should be placed in the .htaccess file of your root directory (assuming your wp-login.php file is in root)

<Files wp-login.php>
order deny,allow
deny from all
allow from xx.xxx.xx.xx
allow from xx.xxx.xx.xxx
</Files>

In code above, replace the “x” values with the actual IP addresses that you wish to allow access to wp-login.php. The code above works on HostGator. If you are having trouble getting this to work, be sure that you keep these statements in all lowercase:

order deny,allow
deny from all

.htaccess files can be quite fickle so trial and error is often required.

Taking this extra step to restrict IP traffic into your WordPress login page is a great way to further reduce the chance of your website being compromised.

Websults w logo
Not Ranking? Let’s Fix What Google Sees.
Fill out my online form.

Search
Blog Categories
Follow Us
Reviews
  • The whole team at Websults are amazing! They did a great job with our website, very professional and extremely helpful. What I thought was going to be a long process couldn't have been more efficient and our old , out dated website was up and running within weeks! Always accessible - Jonathan and team could always be reached - and continue to be available even after the project has been completed. I'd highly recommend Websults for any website work!

    Axion Office Avatar Axion Office
    February 9, 2026
  • Excellent work in creating our website! Competent, professional, creative, responsive, timely and reasonably priced.

    Marc Ayers Avatar Marc Ayers
    July 1, 2025
  • Websults has always been very helpful with any of our site needs!

    Marketing JTCC Avatar Marketing JTCC
    May 1, 2025

Client Reviews

Websults IconWebsults

13555 Automobile Blvd Suite 370, Clearwater

4.8 54 reviews

  • Avatar Axion Office ★★★★★ 3 weeks ago
    The whole team at Websults are amazing! They did a great job with our website, very professional and extremely helpful. What I thought was going to be a long process couldn't have been more efficient and our old , out dated website was up and running within weeks! Always accessible - Jonathan and team could always be reached - and continue to be available even after the project has been completed. I'd highly recommend Websults for any website work!
  • Avatar Marc Ayers ★★★★★ 8 months ago
    Excellent work in creating our website! Competent, professional, creative, responsive, timely and reasonably priced.
  • Avatar Marketing JTCC ★★★★★ 11 months ago
    Websults has always been very helpful with any of our site needs!
  • Avatar Blue Print ★★★★★ 11 months ago
    Websults did a great job working with us to design a better website. Recommend them highly! - Midstate Graphics
  • Avatar Doug Eadie ★★★★★ a year ago
    Jon and his crew at Websults did a great job of designing my company's new web site five years ago and more recently creating a master archive for posts at my three professional blogs. Their service as my company's webmaster has been superb - always responsive and thorough.
  • Avatar Michael Faust ★★★★★ a year ago
    I have been totally satisfied with my new website and the service I have received from Jonathan and his crew at Websults. The website looks amazing and Jonathan collaborated with me to make sure my website was everything I wanted. I would highly recommend his company if you are looking to get a new website!

Websults w logo

Let's Work Together

Use the form to the right to request a price estimate for your next web design, development, or digital marketing project. We normally reply back to online inquiries within 24 hours. Most prospective clients find that our pricing is less expensive than they expected.

Fill out my online form.

Share This
Skip to content