I have a WordPress website on which I have changed the default login url from “mydomain.com/wp-login.php” to “mydomain.com/login”. Currently my lost password URL is at “mydomain.com/login?action=’lostpassword'”. How can I change the URL in order to have it at “mydomain.com/lostpassword”?

I changed the link using the lostpassword_url filter, but now I have to somehow display the default lost password page on the new custom link (it is currently showing "Page not found").

I am not trying to display a custom lost password page, but to display the default lost password page on a custom url.

Thanks for your help!

  • Keep in mind that wp-login.php isn't a permalink but a direct file URL, the WP rewrite rule system won't apply. Changing the URL WP thinks it's at won't be enough either as it'll just lead to a 404 if the original isn't somehow mapped or moved. If it's a redirect you're after though, then that becomes signifiicantly easier to answer. Otherwise it may be impossible without bulding a custom page that's a replica
    – Tom J Nowell
    Commented Aug 11, 2020 at 11:28
  • @TomJNowell I am trying to spoof the Lost Password Page URL in order to not disclose the page where the admin login is located. The idea behind it is that for the website there are two Login pages (one for the users and one for the admins), therefore if the users want to change their passwords I do not want to disclose the admin page. What would be the best solution for this problem?
    – Radu
    Commented Aug 12, 2020 at 8:02
  • So you have a custom login for users, and the admins use the standard WP login? Or have I misunderstood? keep in mind that WP already has nuilt in rewrite rules shortcuts for login and admin at /login and /admin that redirect to the appropriate places. This also won't improve security
    – Tom J Nowell
    Commented Aug 12, 2020 at 8:48
  • Yes, I have a custom login for users and the admins use the standard WP Login. The /login and /admin are already disabled.
    – Radu
    Commented Aug 12, 2020 at 9:06
  • Does this answer your question? How to change/rewrite the lost password url?
    – nmr
    Commented Aug 15, 2022 at 19:08


Your Answer

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

Browse other questions tagged or ask your own question.