Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Help with redirect

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Help with redirect

Postby digitalgravy » Sat Apr 05, 2003 9:44 am

Hello, I am having a problem with a redirect. :x I want to redirect the page based on the refering url. I have the following code:
Code: Select all
<?php
if ($HTTP_REFERER == 'http://www.xxxxxxx.com/xx/xxx.html') {
   header ("Location: /2.html");
   exit;
} else {
   header ("Location: /3.html");
   exit;
}
?>


I want to send anyone who comes from this specific url to page "2.html" and everyone else to page "3.html"

No matter what I do, it always goes to 3.html

I tried it in explorer, netscape and mozilla. All had the same results.

This is probable so simple Im just very new at this stuff. Any help would be greatly appreciated.
If I'm going in the wrong direction with this, please advise me on how to do this. :)

P.S. I thought, maybe there is something up with the server passing on the variable so I tested the following:
Code: Select all
<?php
print ($HTTP_REFERER);
?>

Nothing was displayed.

Thanks
Last edited by digitalgravy on Sat Apr 05, 2003 10:34 am, edited 1 time in total.
User avatar
digitalgravy
New php-forum User
New php-forum User
 
Posts: 32
Joined: Sat Feb 15, 2003 10:00 pm
Location: Los Angeles, CA

Another Part to my question

Postby digitalgravy » Sat Apr 05, 2003 10:30 am

When I use $HTTP_REFERER will that give me just the refering Domain, or the actual page at that domain?

Thanks
User avatar
digitalgravy
New php-forum User
New php-forum User
 
Posts: 32
Joined: Sat Feb 15, 2003 10:00 pm
Location: Los Angeles, CA

Try using the $_SERVER array

Postby andrewdavey » Mon Apr 07, 2003 1:31 am

The HTTP_REFERER value is stored in the $_SERVER (or $HTTP_SERVER_VARS in PHP < 4.0) so try using the following to get the value:
Code: Select all
$_SERVER['HTTP_REFERER']
andrewdavey
New php-forum User
New php-forum User
 
Posts: 16
Joined: Wed Feb 12, 2003 5:27 am
Location: Cornwall, England

Postby digitalgravy » Mon Apr 07, 2003 9:28 am

Thanks andrewdavey,

Ill try that now, but the server has PHP 4.2.3. I also read somewhere that ther server might have "register_globals" turned off, I checked and it says that they are on. Any more suggestions? I will try that other one though.

Thanks Again :D
User avatar
digitalgravy
New php-forum User
New php-forum User
 
Posts: 32
Joined: Sat Feb 15, 2003 10:00 pm
Location: Los Angeles, CA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.