HOME BLOG PORTFOLIO PHOTO CONTACT
404 error page not Found coding using .htaccess

.htaccess code to show your customized error info
run method:
[1]. Make a directory structure like this : C:/wamp/www/jay/seo/404
[2]. Make a file inside  C:/wamp/www/jay/seo/404/index.php
[3]. Make a file inside  C:/wamp/www/jay/seo/404/404.php
[4]. Make a file inside  C:/wamp/www/jay/seo/404/.htaccess
and copy paste below code in appropriate file name
Now run in url
[A]. http://localhost/jay/seo/404/
[B]. http://localhost/jay/seo/404/america.php
Enjoy………..

index.php

**********

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>404 Error Testing</title>
</head>

<body>
<div>Hi This is test page.<br> now try to run this page <br>america.php </div>
</body>
</html>

*************

404.php

*******************

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 3.2//EN”>
<HTML>
<HEAD>
<TITLE>Error Oops! An Error Page not found</TITLE>
<meta http-equiv=”REFRESH” content=”400; url=http://www.google.com”>
<META NAME=”description” CONTENT=”Error of your site”>
<META NAME=”keywords” CONTENT=”many keywords”>
</HEAD>
<BODY>
<p align=”center”>
<h1>This is customized Error Page Error 404 Not found this page</h1>
<p>
<?php
date_default_timezone_set(“Asia/Calcutta”);
$ip = getenv (“REMOTE_ADDR”);
//$ip = $_SERVER['REMOTE_ADDR'];
$requri = getenv (“REQUEST_URI”);
$servname = getenv (“SERVER_NAME”);
$combine = $ip . ” tried to load ->” . $servname .”From ->”. $requri ;
$httpref = getenv (“HTTP_REFERER”);
$httpagent = getenv (“HTTP_USER_AGENT”);
$today = date(“D M j Y g:i:s a T”);
$message = “$today
n $combine
n User Agent = $httpagent
n ref Agent = $httpref “;

$to = “jay@sourcebits.com”;
$subject = “yourdomain Error Page”;
$from = “From: admin@moonreturn.comrn”;

if(@mail($to, $subject, $message, $from))
{
echo “<br>success to sending mail to web site administrator about this error”;
echo “<br>Message=”.nl2br($message);
}
else
{
echo “Message try to send to web administrator through mail but till not success”;
}
?>
</BODY></HTML>

****************


.htaccess

***************


<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 400 test/401.php
ErrorDocument 401 test/402.php
ErrorDocument 403 test/403.php
ErrorDocument 404 test/404.php
AddHandler application/x-httpd-php .php .html .htm .shtml
ErrorDocument 404 http://localhost/jay/seo/404/404.php

*******************
 

   Share on Facebook

Page views:347