How can i do this:

Whenever visitors open the login page (wp-login.php), they will be redirected to the mainpage. Only the admin (me) can view the page to login.

I am doing this to protect my wp sites. Is there any better way to protect WP login page?

1 Answer 1


You can make it so no one can register by clicking off "Anyone can register" in your Admin.

Furthermore, you can choose a really good password, install a login lockdown plugin and enable logins over https. In most cases this is secure enough.

If your really paranoid you can allow access to only your IP by using .htaccess.

<Files wp-login.php>
    order deny,allow
    deny from all
    allow from (your IP)

To do a re-direct you can try something like this in your .htaccess.

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1 (Your IP)
RewriteCond %{REQUEST_URI} !/wp-login\.php$ 
RewriteRule .* http://www.yourhomepage.com [R=403,L]
# 403 is a "forbidden", you can change this to another status code
  • Actually, i get this idea after i read Dreamhost newsletter. They mention their new website now is built on WP. So i try to put /wp-login.php or /wp-admin at the end of their website's URL but what happen is i am redirected to the mainpage. This is what i want to do. Somehow i think only the admin know what is the right URL to login to the WP address. How to achieve this?
    – Dzulfriday
    Sep 20, 2011 at 8:55
  • Updated my answer for a redirect, but in all honestly if you don't know how to do this then you probably don't need to do this. Install a login lockdown plugin instead, who cares if people can reach the login page...
    – Wyck
    Sep 20, 2011 at 18:12
  • the plugin is not updated
    – Dzulfriday
    Sep 21, 2011 at 2:22
  • wordpress.org/extend/plugins/limit-login-attempts Just because a plugin is not up to date does not necessarily mean it does not work.
    – Wyck
    Sep 21, 2011 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.