WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

My site is using a short vanity URL. This is working across all of the custom theme pages. The only problem is when I logout in the admin it redirects to the long URL, which then 404s.

My General Settings (which I can't change) are:

WordPress address (URL): The long URL Site address (URL): The short URL

Looks like the logout link is generated from wp-includes/general-template.php, but I hate to edit core, non-theme, WordPress files.

Any ideas how to solve this logout 404 problem is greatly appreciated.

share|improve this question
up vote 4 down vote accepted

The quickest way to do this is through an Apache rewrite via mod_rewrite. You'll also have to tell WordPress where to points its login links using the login_url and logout_url filters.

  return apply_filters('login_url', $login_url, $redirect);
  return apply_filters('logout_url', $logout_url, $redirect);
share|improve this answer
I'm confused as to what do to to Apache - do I add something to my htaccess file? The login link works fine, so do I only need to edit the logout link (which currently 404s)? I will add your example to my general-template.php file and edited it to include the logout URL. Is this correct: return apply_filters('logout_url', $logout_url, wp-login.php?loggedout=true); – Ryan Mar 15 '11 at 20:59
No that's not correct. Those apply_filters lines are what WordPress is executing. You'll want to add_filter via an add_filter('logout_url', 'function_name'); and have function_name look something like function_name($logout_url, $redirect) { return "http://new.login/link.html"; } or whatever works to alter the $logout_url. Do this in a "must use" plugin (background via hakre: hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins) or maybe via functions.php in your theme folder. – editor Mar 15 '11 at 21:53
Getting there - In my admin, in place of the log in/out buttons is the error "Missing argument 2 for logout_fix." I couldn't find a plugin from your URL so I added this code to functions.php: pastebin.com/QNPWTjs1 – Ryan Mar 16 '11 at 23:04
You sure are getting your money's worth out of me. I see you keep accepting and unaccepting my answer to pump me for additional answers! When you add_filter, try using the 2 extra parameters in add_filter(). The first is the priority, set that to zero (highest). The second is the number of arguments, which is two. Maybe add_filter('logout_url', 'function_name', 0, 2); – editor Mar 17 '11 at 0:04
Sorry - I thought your answer would work but it didn't and I'm desperate :) Will mark once this is resolved I promise! OK, so the extra 2 params did change the logout URL. However, I'm not able to actually logout. If I try returning "domain.com/wp-login.php?action=logout"; it asks me if I want to logout; clicking yes results in an endless "WordPress failure notice" loop. If I return "domain.com/wp-login.php?loggedout=true"; nothing happens. What do I need to change the URL to to logout? – Ryan Mar 17 '11 at 23:19

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.