404 error page

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
webmaster
Forum Newbie
Posts: 4
Joined: Thu Aug 08, 2002 4:48 am

404 error page

Post by webmaster »

I wanna make a 404 error page that also shows which page is asked for but not found.
I tried with request_uri but it doesn't work.
Someone outthere who can help me with code?
hopefully,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What does your code look like? Which version of PHP are you using?

Mac
webmaster
Forum Newbie
Posts: 4
Joined: Thu Aug 08, 2002 4:48 am

Post by webmaster »

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php

echo("$REQUEST_URI");

?>
</body>
</html>

Apache 1.3.26 ; PHP 4.2.2
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Firstly this may be of interest:
http://www.devnetwork.net/forums/viewtopic.php?t=511

Secondly, have you tried:

Code: Select all

echo $_SERVER&#1111;'REQUEST_URI'];
instead of

Code: Select all

echo $REQUEST_URI;
Mac
webmaster
Forum Newbie
Posts: 4
Joined: Thu Aug 08, 2002 4:48 am

Post by webmaster »

that works, but now it gives the url of the 404-page
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Because that's what $_SERVER['REQUEST_URI'] is:
php manual wrote:'REQUEST_URI'
The URI which was given in order to access this page; for instance, '/index.html'.
$_SERVER['HTTP_REFERER'] is probably more what you want:
php manual wrote:'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
All this info is available here:
http://www.php.net/manual/en/reserved.variables.php

Mac
webmaster
Forum Newbie
Posts: 4
Joined: Thu Aug 08, 2002 4:48 am

Post by webmaster »

thx :o :o :D
Post Reply