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

I'm using some code that I found here in order to create a login/logout form on my sidebar. The login works just fine, but what's weird is that on logout, the user gets redirected to "personaldomain.com/%2F", and I get an error that says

Not Found

The requested URL // was not found on this server.

The code for the logout button is:

<a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />

Any advice?

share|improve this question
What happens if you do not use urlencode() which is used anyway in wp_logout_url()s internal code? – toscho Jun 12 '12 at 12:30

According to the codex.. this part:


is unneeded... if you just wan't to logout (pasting from wordpress codex)

<a href="<?php echo wp_logout_url(); ?>" title="Logout">Logout</a>


Logout and Redirect to Current Page

<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>

Logout and Redirect to Homepage

<a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a>

Hope this helps... should always check the codex first ;)

Have a gr8 day,

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.