Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have WP installed in sub-directory and I'd like to have pretty URLs for the lost password functionality. So, something like this, from WP native -> pretty URL:

Initial and any errors lost password page:

http://domain.com/sub-dir/wp-login.php?action=lostpassword -> http://domain.com/sub-dir/forgot-password

Success URL of the lost password page:

http://domain.com/sub-dir/wp-login.php?checkmail=confirm -> http://domain.com/sub-dir/forgot-password?checkmail=confirm

I've tried using the following code: a re-write rules and a filters.

The re-write rules:

add_rewrite_rule( 'forgot-password?checkemail=confirm/?$', 'wp-login.php?checkemail=confirm', 'top' );
add_rewrite_rule( 'forgot-password/?$', 'wp-login.php?action=lostpassword', 'top' );

The filters:

add_filter( 'lostpassword_url', 'lostpass_url_fix');
function lostpass_url_fix( $link ){
    return str_replace( '?action=lostpassword', '', str_replace( network_site_url('wp-login.php', 'login'), home_url( 'forgot-password', 'login'), $link ) );

add_filter( 'lostpassword_redirect', 'lostpassword_redirect_fix' );
function lostpassword_redirect_fix(){
    return home_url( 'forgot-password?checkemail=confirm', 'login' );

However, that doesn't seem to work correctly. Whether it's a success or failure it's always redirected to forgot-password?checkemail=confirm without any error/success messages.

I've noticed that WP native lost password behavior is the following:

1) Success. The URL is wp-login.php?checkmail=confirm that displays login form with message to check user's email for the login details.

2) Failure. The URL is wp-login.php?action=lostpassword that displays lost password page with the error message.

In the lostpassword_redirect filter I don't think I can test for success or failure of the lost password function..

Any idea how it's possible to make URLs for the lost password functionality pretty?

Many thanks, Dasha

share|improve this question
Here is the initial tutorial that I have followed of making native WP login related URLs pretty: en.bainternet.info/2012/… However, it doesn't cover the 'lost password' URls as much, hence I'm trying to figure out how to do it :) –  dashaluna Apr 29 '13 at 16:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.