question about customized error

This is a discussion on question about customized error within the PHP General forums, part of the PHP Programming Forums category; if a user by mistake types the wrong url directly in the address bar ex= www.website.com/abou.php ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-20-2008
Sudhakar
 
Posts: n/a
Default question about customized error

if a user by mistake types the wrong url directly in the address bar ex=
www.website.com/abou.php instead of
typing www.website.com/aboutus.php instead of the browser displaying File
not found or a 404 error message i would like to display a customized page
which will still have the same look and feel of my website in terms of the
layout and i would like to
a) display a message such as = "Page could not be found" and b) the url that
the user originally typed should remain in the browser = I guess this would
be the case anyway but i was wondering if something needs to be done in
order to reatin the original address the user typed.

Does this have to be done from apache perspective or can it be done using
php. please suggest the procedure in either case apache OR php.

please advice.

thanks.

Reply With Quote
  #2 (permalink)  
Old 03-21-2008
Jim Lucas
 
Posts: n/a
Default Re: [PHP] question about customized error

Sudhakar wrote:
> if a user by mistake types the wrong url directly in the address bar ex=
> www.website.com/abou.php instead of
> typing www.website.com/aboutus.php instead of the browser displaying File
> not found or a 404 error message i would like to display a customized page
> which will still have the same look and feel of my website in terms of the
> layout and i would like to
> a) display a message such as = "Page could not be found" and b) the url that
> the user originally typed should remain in the browser = I guess this would
> be the case anyway but i was wondering if something needs to be done in
> order to reatin the original address the user typed.
>
> Does this have to be done from apache perspective or can it be done using
> php. please suggest the procedure in either case apache OR php.


Both will be involed.

You will use what is referred to as the ErrorDocument entry.

Have apache enforce a customer ErrorDocument for a 404 error.

Then create a php script that is referred to by the ErrorDocument entry.

error404.php

<?php

echo "Page not found, check your spelling and try again.";

?>

>
> please advice.
>
> thanks.
>



--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

Reply With Quote
  #3 (permalink)  
Old 03-21-2008
M. Sokolewicz
 
Posts: n/a
Default Re: [PHP] question about customized error

Jim Lucas wrote:
> Sudhakar wrote:
>> if a user by mistake types the wrong url directly in the address bar ex=
>> www.website.com/abou.php instead of
>> typing www.website.com/aboutus.php instead of the browser displaying File
>> not found or a 404 error message i would like to display a customized
>> page
>> which will still have the same look and feel of my website in terms of
>> the
>> layout and i would like to
>> a) display a message such as = "Page could not be found" and b) the
>> url that
>> the user originally typed should remain in the browser = I guess this
>> would
>> be the case anyway but i was wondering if something needs to be done in
>> order to reatin the original address the user typed.
>>
>> Does this have to be done from apache perspective or can it be done using
>> php. please suggest the procedure in either case apache OR php.

>
> Both will be involed.
>
> You will use what is referred to as the ErrorDocument entry.
>
> Have apache enforce a customer ErrorDocument for a 404 error.
>
> Then create a php script that is referred to by the ErrorDocument entry.
>
> error404.php
>
> <?php
>
> echo "Page not found, check your spelling and try again.";
>
> ?>
>
>>
>> please advice.
>>
>> thanks.
>>

>
>


With it being apache, you could also do it using SHTML (apache's subset
of some simple extra tags to make files dynamic without having to load
an entire PHP parser for it). But yes, it is as Jim Lucas posted; used
quite a lot even.

- Tuk
Reply With Quote
  #4 (permalink)  
Old 03-21-2008
Daniel Brown
 
Posts: n/a
Default Re: [PHP] question about customized error

On Thu, Mar 20, 2008 at 6:54 PM, Sudhakar <sudhakararaog@gmail.com> wrote:
> if a user by mistake types the wrong url directly in the address bar ex=
> www.website.com/abou.php instead of
> typing www.website.com/aboutus.php instead of the browser displaying File
> not found or a 404 error message i would like to display a customized page
> which will still have the same look and feel of my website in terms of the
> layout and i would like to
> a) display a message such as = "Page could not be found" and b) the url that
> the user originally typed should remain in the browser = I guess this would
> be the case anyway but i was wondering if something needs to be done in
> order to reatin the original address the user typed.


..htaccess:
ErrorDocument 404 /404.php

404.php:
<?php
// Whatever you want here.
?>

--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
Reply With Quote
  #5 (permalink)  
Old 03-23-2008
Nilesh Govindrajan
 
Posts: n/a
Default Re: question about customized error

Sudhakar wrote:
> if a user by mistake types the wrong url directly in the address bar ex=
> www.website.com/abou.php instead of
> typing www.website.com/aboutus.php instead of the browser displaying File
> not found or a 404 error message i would like to display a customized page
> which will still have the same look and feel of my website in terms of the
> layout and i would like to
> a) display a message such as = "Page could not be found" and b) the url that
> the user originally typed should remain in the browser = I guess this would
> be the case anyway but i was wondering if something needs to be done in
> order to reatin the original address the user typed.
>
> Does this have to be done from apache perspective or can it be done using
> php. please suggest the procedure in either case apache OR php.
>
> please advice.
>
> thanks.
>


..htaccess:

ErrorDocument 404 /404-error.php

404-error.php:

<?php

.....soem code

?>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:00 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0