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


on my wordpress page i have a form and i am redirecting my wordpress page to some other website after form submit

i have following code in my functions.php file for submitting form.

add_action('init', 'redirect');
function redirect(){
    wp_redirect("www.google.com",301); exit();


but its not redirecting and showing 404 error and following url on submit http://www.mywebsite.com/my-post/www.google.com

here i am using shortcode to display form on my wordpress page.

what is the reason? any clue?

share|improve this question
Lowercase $_post might be your problem. Try $_POST instead. If that doesn't work, I'll work up an answer for you using a different route. – Brian Fegter Mar 4 '12 at 21:30
i am using $_POST in functions.php file. here i just wrote in hurry. – naeplus Mar 4 '12 at 21:30
this is not the issue. i try this also. please try different route. – naeplus Mar 4 '12 at 21:31
What about http:// in front of your URL? – Brian Fegter Mar 4 '12 at 21:34
Great.. Its just started working. thank you so much. please post answer bellow. so you can take credit. – naeplus Mar 4 '12 at 21:42
up vote 1 down vote accepted

You need to place http:// in front of the URL for wp_redirect to work properly.

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.