Server Fault is a question and answer site for system and network 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 get a 404 page when loging in to wordpress for all my users. It adds an extra "/" so its like

I am using:<?php wp_loginout(urlencode($_SERVER['REQUEST_URI'])); ?>

So that after a user logs in, it brings them back to where they were.

Is there something wrong with that code? Any ideas? This might help: Thanks

share|improve this question
Is there a reason why you're running urlencode() on REQUEST_URI? It appears WP already has an esc_url() function that parses that variable when you run wp_loginout. Perhaps too much escaping is causing the extra slash? – James Jun 19 '10 at 3:42
up vote 0 down vote accepted

OK. I actually had a few minutes to test this on my Wordpress 2.9.2 blog.

The issue you are having, as mentioned in my comment, is that you're escaping $_SERVER['REQUEST_URI'] in your paramters of wp_loginout(). That function, wp_loginout(), already has a url cleanser called esc_url().

So, if you just write...

<?php wp_loginout($_SERVER['REQUEST_URI']); ?>

... your code will work as you want it to.

share|improve this answer
James works great. I really appreciate it. I had taken the code from some forum, no idea what it meant. Wish i could give you plus1 :) not enough reputation... – thegreyspot Jun 19 '10 at 4:33
No worries. I'm glad it worked. Escaping strings can always be a tricky endeavor in PHP development. Every function does it different or behaves in a way that puzzles one for hours. – James Jun 19 '10 at 6:03

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.