Randy
02-10-2004, 03:09 PM
Here's how to create a custom 404 page.
First, create the page you want to display. Save it as 404.php.
In that page, you can have certain things displayed. Just put the appropriate code where you want it displayed in your page. You can use this information on any other PHP page too.
Information available:
A query string, if you use dynamic pages
<?php echo $_SERVER["QUERY_STRING"]; ?>
The page the user came from
<?php echo $_SERVER["HTTP_REFERER"]; ?>
The page the user was trying to visit
<?php echo $_SERVER["REQUEST_URI"]; ?>
The user's IP address
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
The user's browser
<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>
The next thing to do is to create an .htaccess file. These are special files that tell the web server how to behave. If you already have a .htaccess file, just add the information to the bottom.
Steps to create a .htaccess file from scratch:
[list]
Open your favorite text editor (TextEdit in plain-text mode on Mac OS X or Notepad on Windows).
Add this to the file:
ErrorDocument 404 /404.php
Save the document as ".htaccess". If you're on Mac OS X, don't type the quotes and don't append a file extension. If you're on Windows, include the quotes around the name.
Upload the .htaccess file to your www or public_html folder. See this post for FTP Instructions (http://forums.insiderhosting.com/showthread.php?s=&threadid=1606).
You're all set!
First, create the page you want to display. Save it as 404.php.
In that page, you can have certain things displayed. Just put the appropriate code where you want it displayed in your page. You can use this information on any other PHP page too.
Information available:
A query string, if you use dynamic pages
<?php echo $_SERVER["QUERY_STRING"]; ?>
The page the user came from
<?php echo $_SERVER["HTTP_REFERER"]; ?>
The page the user was trying to visit
<?php echo $_SERVER["REQUEST_URI"]; ?>
The user's IP address
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
The user's browser
<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>
The next thing to do is to create an .htaccess file. These are special files that tell the web server how to behave. If you already have a .htaccess file, just add the information to the bottom.
Steps to create a .htaccess file from scratch:
[list]
Open your favorite text editor (TextEdit in plain-text mode on Mac OS X or Notepad on Windows).
Add this to the file:
ErrorDocument 404 /404.php
Save the document as ".htaccess". If you're on Mac OS X, don't type the quotes and don't append a file extension. If you're on Windows, include the quotes around the name.
Upload the .htaccess file to your www or public_html folder. See this post for FTP Instructions (http://forums.insiderhosting.com/showthread.php?s=&threadid=1606).
You're all set!