Thread: URL Redirecting

  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Rep Power
    How can I redirect a page using PHP?
    Thank you in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Rep Power
    First thing to do is to do a search of this forum for redirect. There are many posts from from others asking this same question.


    The way to redirect with PHP is to use header(). The only problem is that header() must be at the top of the document. That includes any HTML tags and even whitespace. An example script would be:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <? $url = urlencode(""); ?>
    <A HREF="redirect.php?url=<? print($url); ?>">Link</A>

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    if($url) {
    header("Location: $url");

    The reason for urlencode() is that you will have problems if you try to pass a url that has items in the querystring.

    [This message has been edited by chris22 (edited October 29, 2000).]

Similar Threads

  1. How to rewrite URL with Perl redirecting?
    By fablau in forum Perl Programming
    Replies: 5
    Last Post: January 17th, 2004, 09:50 AM
  2. redirecting url
    By brian110872 in forum PHP Development
    Replies: 1
    Last Post: January 4th, 2004, 02:48 PM
  3. Url Redirecting
    By brian110872 in forum Perl Programming
    Replies: 3
    Last Post: November 9th, 2003, 12:47 PM
  4. redirecting to another URL on a different site
    By hllywdw in forum Java Help
    Replies: 1
    Last Post: October 1st, 2003, 04:54 AM
  5. Need help: redirect to page based on text in URL
    By JPElectron in forum HTML Programming
    Replies: 2
    Last Post: July 18th, 2003, 11:44 PM

IMN logo majestic logo threadwatch logo seochat tools logo