WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use other link for logout because i have /wp-admin/* protected with htpassword. Is there a way to do this? Something like create a custom page like site.com/logout then use it as my new logout link?


share|improve this question

You can filter 'logout_url' and return a custom value if you are in the admin area:

add_filter( 'logout_url', 'wpse_58453_logout_url' );
function wpse_58453_logout_url( $default ) 
    // set your URL here
    return is_admin() ? 'http://example.com/custom' : $default;
share|improve this answer
But why do i get 404? I tried mysite.com/logout but i get 404 do i need to add some code on the end url? – tiltdown Jul 14 '12 at 7:12
Well, the target should exist somewhere. :) You could create a custom endpoint (example). – toscho Jul 14 '12 at 7:15
What will do with the endpoint? I created a page called 'logout' and it just redirects it there what do i need to add on the logout page? Thank you for your reply. – tiltdown Jul 14 '12 at 7:27
I am not sure if I still follow you … maybe that’s a separate question? – toscho Jul 14 '12 at 8:21
No same question. Here's the thing i followed your function added it on my custom function file then made it to "mysite.com/logout" the logout is a WordPress page. When i do <?php echo wp_logout_url( ); ?> it gives me a the right logout url which is mysite.com/logout but when i click on it it will just redirect me to the /logout WordPress page. Do i need to setup any code on my /logout page on wordpress? – tiltdown Jul 14 '12 at 8:27

I think you should add rewrite rule in your htaccess file like this.

RewriteRule ^logout/(.*) /wp-login.php?action=logout&_wpnonce=$1 [QSA,L]
share|improve this answer

Your Answer


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

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