Archive for the ‘Web Pages’ Category

Get Notified of 404 Errors

Saturday, January 13th, 2007

One addition I have found useful is to add email notification when my custom 404 page is invoked. Since I use a PHP file for the custom 404 adding email notification is pretty easy. I renamed the original custom404.htm to custom404.php then added the email code.

The email sent will spell out the invalid page that caused the 404 error. BTW, 404 is the error generated by HTTP when an invalid or nonexistent web page is trying to be accessed. The commented out echo code was used for diagnostics.

Note that nothing is shown on the custom 404 page. The email occurs behind the scenes.

Here is the code:


<?php
// send error email
$em = "someone";
$em .= "@";
$em .= "mydomainname";
$em .= ".com";

$subject="Custom404";
$message="A custom 404 page was accessed from mysecurepc site";
$message .= " The page accessed was: " . $_SERVER['REDIRECT_SCRIPT_URI'];

if(mail("$em","$subject","$message","From: $em")){
//echo "e-mail sent !!!";
}else{
//echo "error !!!";
}
?>

A few things I have noticed since I set this up on a couple of web sites for testing.

1. For some reason, I get a custom 404 email when a bookmark like

...domain.com/folder/webpage.html#topofpage

is accessed. I have not been able figure out why, yet.

2. If you do not have a favicon.ico then the custom 404 page is invoked and you will get email. This occurs when IE accesses the home page.

3. Deleted web pages may show up in an 404 email since search engines retain these links for a while. The searchbots invoke these.

4. Deleted or name-changed web pages may show up because someone is using an old link.

Overall it has given me valuable feedback despite some unwanted emails.

Doug

Expression Web Validation Discontinuity

Sunday, December 10th, 2006

I have come to like Microsoft Expression Web…definitely better than FrontPage 2003. One feature I use is the compatibility report which checks the web page under construction against a standard, such as XHTML 1.0 Strict. Come to find out I posted a valid web page (XHTML 1.0 Strict) but when I checked it against W3C it failed. I’m hoping this will get fixed soon.

Doug

Control over Using ODP Information

Saturday, December 2nd, 2006

For site owners included in ODP (Open Directory Project) the information is displayed as a default on search results. Google now gives webmasters the option to add a simple meta tag to their webpages to tell the search engine not to display their ODP (Open Directory Project) information:

Insert the following anywhere between the header tags:

<meta name="GOOGLEBOT" content="NOODP" />

This works only for the google bot, so not every search engine who uses the ODP will immediately follow suit. Here’s the code that applies to all search engines who choose to use it:

<meta name="ROBOTS" content="NOODP" />

I understand about 90% of the site descriptions contained in the ODP is outdated so using the out-of-date information is detrimental to the website owner.

Doug

Tab Order on your Web Site

Sunday, November 12th, 2006

When working in industry on applications, I spent time making sure the tab order was working and in an intuitive order. BTW, to move from element to element one can use the Tab key.
This also holds true for web pages. The WCAG (web content accessibility guidelines) says that Anchor, AREA, BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA elements need the tab order set. The tab order is helpful to anyone.
Each element has a tabindex attribute which is a number starting with 1 which increases sequentially for each element. The focus starts at tabindex 1 and moves to 2 then 3… as the tab key is pressed.
I have yet to find an automated way of setting the tab order.

Doug

Got Custom 404 Page?

Sunday, November 12th, 2006

I am surprised at how many websites do not have custom 404 pages.
Try entering a nonexistent web page for your website.
And what is a custom 404 page? A response to a web page not found. If a web page is not found on your site, the server returns a 404 error. Normally the web host has a default web page in response to a 404 error. Most web hosts allow a custom 404 page which you can put just about anything you want on it. And a link to the homepage can be put on; something a default 404 page does not have.

Check with your web host on how to redirect a 404 to your custom 404 page. Each host has its own peculiarities.

The .htaccess file can be modified to point to a custom 404 page (note .htaccess file is only for Apache servers). Add the following line:

ErrorDocument 404 http://www.mydomain.com/404-error-page.php

Replace mydomain with your domain. Note the error page can be an html file instead of a php file. This worked fine if the error page was an html page but did not work if it was a php page.

A better way is this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.htm

where /errordocument.htm is the custom 404 page for your site. This can also be a php script such as custom404.php. Note this goes in the root directory. Just add directories like this: /dir1/dir2/errordocument.php

This method worked fine for nonexistent html and php pages.
Doug