Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall
As an owner of a conscious web Developer/website, you may want to track 404 pages of your site or blog. Of course you can analyze your site's access log files, but today we're going to talk about a better way to track them by sending email reports. So I will be able to more timely access to the 404 page situation.
If your topic does not have a 404.php file, you must create it and then add the code to your 404 page:
<?php
Set page status
Header ("http/1.1 404 Not Found");
Header ("status:404 not Found");
Site information
$blog = Get_bloginfo (' name ');
$site = get_bloginfo (' url '). '/';
$email = Get_bloginfo (' Admin_email ');
Subject Information
if (!empty ($_cookie["Nkthemeswitch"). Cookiehash])) {
$theme = Clean ($_cookie["Nkthemeswitch"). Cookiehash]);
else {
$theme _data = Wp_get_theme ();
$theme = Clean ($theme _data->name);
}
//Get Source Address
if (isset ($_server[' http_referer ')) {
$referer = clean ($_server[' http_referer ']);
} else {
$referer = "undefined";
}
//source URI
if (isset ($_server[' Request_uri ')) && isset ($_server["Http_host"])) {
$request = Clea N (' http://'. $_server["Http_host"]. $_server["Request_uri");
} else {
$request = "undefined";
}
//query string
if (isset ($_server[' query_string ')) {
$string = clean ($_server[' query_string ']);
} else {
$ string = "undefined";
}
//IP address
if (isset ($_server[' remote_addr ')) {
$address = clean ($_server[' remote_addr ']);
} else { br> $address = "undefined";
}
//User Client Information Agent
if (isset ($_server[' http_user_agent ')) {
$agent = clean ($_server[' http_user_agent ') );
} else {
$agent = "undefined";
}
//User Connection Agreement
if (isset ($_server[' remote_ident ')) {
$remote = clean ($_server[' remote_ident ']);
} else {
$remote = "undefined";
}
//record time
$time = Clean (date ("Y-m-d h:i:s", Time ());
Combining information
function Clean ($string) {
$string = RTrim ($string);
$string = LTrim ($string);
$string = Htmlentities ($string, ent_quotes);
$string = Str_replace ("n", "<br>", $string);
if (GET_MAGIC_QUOTES_GPC ()) {
$string = Stripslashes ($string);
}
return $string;
}
$message =
"Time:". $time. "N".
"* 404:". $request. "N".
"SITE:". $site. "N".
"THEME:". $theme. "N".
"REFERRER:". $referer. "N".
"QUERY STRING:". $string. "N".
REMOTE address:. $address. "N".
"REMOTE IDENTITY:". $remote. "N".
USER AGENT:. $agent. "NNN";
Send mail
Mail ($email, "404 Alert:". $blog. " [" . $theme. "]", $message, "from: $email");
?>
Note: Use this method if your WordPress support mail is sent.
Reprint Please specify: http://www.54ux.com/a-2393.html