Custom 404 Error Messages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Custom 404 Error Messages

Post by rapaddict_dot_com »

I have a custom 404 script and I wanna make it so it says

you were refered from : blah blah

and I want the address bar to have the address to the page they were trying to find

how can I do this?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

1) i really don't think this is the appropriate forum, but i have no power over that
2) to get the referrer, try:

Code: Select all

$ref = $_SERVER['HTTP_REFERRER'];
3) address abr to have teh address to the page they were trying to find?? How are you going to do that? read their mind?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you use the apache directive ErrorDocument 404 /your404page.php then the address bar should retain the original link they were trying to find. Does for me anyway :o
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post by rapaddict_dot_com »

$ref = $_SERVER['HTTP_REFERRER'];

^that doesnt work for me
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Should be $_SERVER['HTTP_REFERER']; and it won't always be set, so better do a if(!empty($_SERVER['HTTP_REFERER'])){ ... }
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to PHP - Code.

Mac
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post by rapaddict_dot_com »

thanks
Post Reply