Security and SSL
Renaming wp-login.php to protect access: how to do it today without breaking WordPress
The wp-login.php file is the entrance to the WordPress dashboard (wp-admin takes you to it). As it is at the same address on every website, bots attack it daily with brute-force attacks: they try thousands of usernames and passwords.
Years ago the usual solution was to rename the file (for example to oculto.php) and change every occurrence of wp-login.php inside it. Today we do not recommend it: WordPress recreates wp-login.php on every update, and the rest of the core keeps generating links to wp-login.php for logging out, recovering the password or confirming actions, so those functions stop working.
There are two ways to achieve the same thing without touching the core.
Option 1: change the login address with a plugin
The free WPS Hide Login plugin does exactly what you were looking for when renaming the file: you choose a new address (for example tudominio.com/acceso-k7m2q) and wp-login.php and wp-admin return an error to anyone who has not logged in. Updates do not undo it and password recovery keeps working.
You have the steps in protect wp-admin and wp-login with WPS Hide Login.
Option 2: allow wp-login.php only from your IP
If you always manage the website from the same connection (the office, for example), you can keep wp-login.php closed to everyone except you. It is more secure than hiding it.
- Find out your public IP by searching Google for "what is my IP".
- Open the .htaccess file in the WordPress folder from the cPanel File Manager.
- Add at the beginning, replacing the example IP with yours:
<Files wp-login.php> Require ip 203.0.113.10 </Files>
If you log in from several connections, put them separated by spaces on the same line: Require ip 203.0.113.10 198.51.100.25.
From any other IP, wp-login.php will return a 403 error. Visitors notice nothing: it only affects the login form.
Bear in mind that many home connections change IP from time to time. If one day you cannot get in, update the IP in the .htaccess from the File Manager. Do not use this option if your website has customers or partners who log in (WooCommerce shops, private areas, forums).
If your IP changes often, you can limit wp-admin to your country instead of to your IP.
If you already renamed wp-login.php with the old guide
Put the original file back so that everything works:
- Check your WordPress version in Dashboard > Updates (or in the
wp-includes/version.phpfile,$wp_versionline). - Download that same version from the WordPress releases archive and unzip it on your computer.
- Upload its
wp-login.phpto the WordPress folder, replacing whatever is there. - Delete the renamed file (
oculto.phpor whatever name you used). - Remove from the
.htaccessthe block that blockedwp-login.php:
<Files wp-login.php> Order Allow,Deny Deny from all </Files>
- Log in at
tudominio.com/wp-login.php, try logging out and recovering the password, and apply one of the two options above.
Hiding the login stops bots, but it does not protect you if someone already has your password. Complete the protection with unique passwords, two-step verification for administrators and up-to-date software, as explained in the security tips for WordPress.
You may also find useful
- Secure WordPress and keep its access under control Brings together measures to harden WordPress through updates, unique passwords, 2FA and extra protec...
- Unmaintained WordPress plugins: how to spot them and why they are a risk How to check the last update date and compatibility of WordPress plugins and themes, before installi...
- WordPress security plugins: do you need them at Hostsuar? Why we do not recommend security suites such as Wordfence, AIOS or Kadence Security on our hosting,...
- Configure session cookie security in GLPI Check HTTPS and GLPI's effective PHP configuration to resolve Secure cookie warnings, without confus...
Something wrong or out of date? Tell us and we will review it.