How to redirect page using PHP with values?

Here is the code for simple PHP page redirect. The search engine friendly way of redirecting is the 301 redirect.

1
2
3
4
<?php
	Header("HTTP/1.1 301 Moved Permanently"); 
	header( 'Location: http://www.yoursite.com/page.html' ) ;
?>

Note that if you do not include the first Header line above, the redirect still works. But, instead of a 301 redirect, now it becomes a 302 (temporary) redirect.

Now if you want to redirect to perticluer user page then you need to include user id in the url. Here is the code:

1
2
3
<?php
	header("Location: userpage.php?id=".$userId);
?>

177 Responses to “How to redirect page using PHP with values?”

  1. Meagan Nelson

    A person necessarily assist to makke significantly articles
    I would state. This iis tthe very first time I frequented your website
    page and thus far? I surprised with the analysis yoou made to create this
    actual submit incredible. Great activity!

    Reply
  2. Adrianna Schultz

    Article writing is also a excitement, if you be familiar with after that you can write if not
    it is complex to write.

    Reply
  3. Retha Holliday

    You ought to take part in a contest for one of the best blogs on the web.
    I’m going to highly recommend this site!

    Reply
  4. Ferdinand Neil

    I blog often and I seriously thank you for your information. Your article
    has truly peaked my interest. I’m going to book mark your site and keep checking for new
    information about once a week. I opted in for your Feed as well.

    Reply
  5. Bernardo Maxted

    I do not know if it’s just me or if perhaps everybody else experiencing problems with your website.
    It appears as if some of the written text in your content are running off the screen. Can someone else please provide feedback and
    let me know if this is happening to them as well? This may be a problem with my internet browser because I’ve had this
    happen before. Many thanks

    Reply
  6. Hollie Stiltner

    This is really interesting, You’re an overly professional blogger.
    I’ve joined your rss feed and look forward to in search of extra of your fantastic post.
    Also, I’ve shared your website in my social networks

    Reply
  7. Ronald Asher

    For latest news you have to pay a visit world-wide-web and on world-wide-web I found this site as a most
    excellent website for most recent updates.

    Reply
  8. Erik Barkley

    Hello there, You’ve done a fantastic job. I’ll definitely digg it and personally suggest to my friends.
    I am sure they’ll be benefited from this website.

    Reply
  9. Hilario Mate

    What i do not understood is actually how you’re now not really
    a lot more well-appreciated than you might be now. You’re
    so intelligent. You recognize therefore significantly relating to this
    matter, made me individually imagine it from so many numerous angles.
    Its like men and women are not involved unless it is something to accomplish with
    Girl gaga! Your personal stuffs outstanding. All the time maintain it up!

    Reply
  10. Winston Waldrup

    This article is really a pleasant one it assists new net users, who are wishing in favor of
    blogging.

    Reply
  11. Georgina Phan

    Magnificent site. Lots of helpful info here. I’m sending it to some pals ans additionally sharing in delicious.
    And of course, thank you to your sweat!

    Reply

Leave a Reply