# 404 Error Customization--Server Side Part

**URL:** <https://forum.kirupa.com/t/404-error-customization-server-side-part/116994>\
**Category:** Uncategorized\
**Created:** [July 23, 2004, 4:43am UTC](https://forum.kirupa.com/t/404-error-customization-server-side-part/116994 "2004-07-23T04:43:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [July 23, 2004, 4:43am UTC](https://forum.kirupa.com/t/404-error-customization-server-side-part/116994/1 "2004-07-23T04:43:13Z")

</div>

I know you can change your .htaccess to have your 404 error display the page you typed in at the top (in the address bar)

How do you do that?

(Hehehehe, I love my 404th post)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2004, 4:51am UTC](https://forum.kirupa.com/t/404-error-customization-server-side-part/116994/2 "2004-07-23T04:51:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2004, 4:53am UTC](https://forum.kirupa.com/t/404-error-customization-server-side-part/116994/3 "2004-07-23T04:53:01Z")

</div>

```php
<?php
$location = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
echo $location;
?>

```

that’ll give you your current location, then if you just want the file take out what you don’t need of course 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2004, 5:21am UTC](https://forum.kirupa.com/t/404-error-customization-server-side-part/116994/4 "2004-07-23T05:21:28Z")

</div>

> [@Krilnon](#):
>
> I know you can change your .htaccess to have your 404 error display the page you typed in at the top (in the address bar)
> 
> How do you do that?
> 
> (Hehehehe, I love my 404th post)

In case you’re asking about the .htaccess file instead of the CGI side of things (or for reference for anyone else), the line is:

> 

ErrorDocument 404 “/404.php”

You can replace ‘404’ for any HTTP error code (403, 401, 500 would be good choices), and replace ‘404.php’ with the actual filename of the script you want to handle the printing…
