get url of not found 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
amao
Forum Newbie
Posts: 21
Joined: Sun May 10, 2009 5:13 am

get url of not found page

Post by amao »

HI all
I need to make customize page to catch any not found page 404.php, I need to url of the page that not found
Ex: my site is http://www.mysite.com/page.php , and the user type http://www.mysite.com/pagg.php
I need to know that the user call pagg.php
I try this code but did not give write result

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
    <title>404: Page Not Found</title>
    <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" />
 </head>
 <body>
 <h1>404: Page Not Found</h1>
 <?php
 echo "the target url is";   
      $requri = $_SERVER['REQUEST_URI'] ;
 echo $requri;
 ?>
 </body>
 </html>
 
but it gives me /404.php
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: get url of not found page

Post by Mark Baker »

Look at the value of $_SERVER['REDIRECT_URL']
amao
Forum Newbie
Posts: 21
Joined: Sun May 10, 2009 5:13 am

Re: get url of not found page

Post by amao »

Mark Baker wrote:Look at the value of $_SERVER['REDIRECT_URL']
it give me this error
Notice: Undefined index: REDIRECT_URL in C:\wamp\www\404.php on line 12
Post Reply