Get Notified of 404 Errors

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

Gold Coins

January 13th, 2007

Gold has always been a hedge against rampant inflation. Gold and gold coins have bought the passage to safety where other forms of money have failed. Since the United States has operated in a pro-inflation mode (rather than deflation) the yellow metal has has an allure of some protection. While most people are against inflation, unfortunately it is part of our life. Many financial planners have recommended precious metals such as gold as part of an overall portfolio. Consider one aspect of portfolio hedge and purchase gold, whether it be American Eagles, Krugerrands, or Maple Leafs for an adjunct to long-term financial security. Ask your financial adviser before investing.

How to Password a Folder on an Apache Server

December 31st, 2006

This only works for an Apache server. Note that the folder and its contents will not be indexed since it is passworded.

1. create .htaccess and .htpasswd as ordinary text files. Make sure there is no .txt at the end.

here is an .htaccess example

AuthUserFile /home/content/f/r/e/fred/html/myfolder/.htpasswd
AuthGroupFile /dev/null
AuthName "Access for Admin"
AuthType Basic

<limit GET POST>
require user myfriends
</limit>

where myfriends (replace with your own) is the login id and the folder to protect is myfolder (replace with your own directory path)

line 1 of .htaccess needs to be replaced with the full path on your server to your .htpasswd folder. This is dependent on your ISP. The example shown below is from GoDaddy. The path to the root of your GoDaddy account looks like:

/home/content/f/r/e/fred/html/

This is known as the DOCUMENT_ROOT in the world of PHP. Since most hosts support php you can create a file called showinfo.php and put the following into it:


<? phpinfo(); ?>

Upload this to your website’s home directory and invoke it:

http://www.mydomain.com/showinfo.php

Look for the entry called “DOCUMENT_ROOT”.
for example if DOCUMENT_ROOT was /home/content/f/r/e/fred/html/ and the folder you are trying to protect is myfolder then the entry for AuthUserFile is:

/home/content/f/r/e/fred/html/myfolder/.htaccess

Ask your ISP if you cannot find the full path.

Here is an .htpasswd example

myfriends:bZTGwg.9OWALY

  • where myfriends is the login id and the stuff after the colon is the encrypted password.
  • make sure .htpasswd is one line only with no breaks at the end

to get the .htpasswd entry you need to generate a password. Try this link:

Generate .htpasswd

It will generate a cut-and-paste line for .htpasswd. Remember no breaks at the end of the line.

If you have access to Perl, try this from the command line:

perl -e "print crypt('myfriends', 'abc')"

where the ‘myfriends’ is the login id and ‘abc’ can be any sequence of letters or numbers. It provides a starting point for the password.

2. upload .htaccess and .htpasswd to the folder you want passworded. If you have a problem uploading try this link:

Uploading the .htaccess file

3. you are done. Every time someone tries to access the folder or any of its subfolders they will be prompted for a login and password.

Doug

WordPress is Slow After Posting

December 28th, 2006

Like most people, I have experienced a very frustrating waiting period after I hit Publish in WordPress. It takes forever sometimes. Or the white screen of death: MySQL database access has timed out (or a similar message). Why is this happening?

The default for WordPress is to ping the pingomatic website after a post is published. Look under Options > Write and look under Update Services. There is a reference to pingomatic which pings many, many servers. When all the pinging is done then control is returned…if ever. The default timeout is 15 seconds.

There are several ways around this.

1. Have a service, such as FeedBurner, do your bidding. Delete the entries in the Update Service area and have the service (FeedBurner e.g.) handle your feed. FeedBurner has an option called PingShot which, when activated, will ping pingomatic and other servers. I use a plugin called subscribe me which routes your blog’s feed requests to FeedBurner.

2. A plugin called wp-no-ping-wait will ping the list in Update Service *after* control is returned to WordPress. Thus after Publish button is pressed control is returned almost immediately. The website that handles the plugin has been down for a while so go to this link to get it (the wayback machine). Look for nopingwait2.php. Upload it to your plugin directory and activate it.
3. Delete all entries under Update Service and manually ping the servers yourself using pingoat or pingomatic.

Doug

Link Popularity for Blogging

December 10th, 2006

Most online people have their own web sites. For business owners web site is almost mandatory. One of the best ways to improve link popularity and traffic of a website is by blogging. Up to date information can be posted quickly, giving viewers an edge. A way to increase quality links to your web site is to have others write blog articles about your niche. This service is a way to quickly get many links pointing to your web site. Search engines use quality links as an important part of their algorithm for rating a web site. This is one avenue worth investigating.

Doug

Web Beacon

December 10th, 2006

A web beacon is also known as a web bug, pixel tag, or a clear GIF.
Used in combination with cookies, a web beacon is an often-transparent (i.e. hidden) graphic image, usually the size of 1 pixel x 1 pixel, that is placed on a Web site or in an e-mail that is used to monitor the behavior of the user visiting the Web site or sending the email. When the HTML code for the web beacon points to a site to retrieve the image, at the same time it can pass along information:

  • The IP address of the computer that retrieved the image
  • The time the web beacon was viewed
  • How long the page was viewed
  • The type of browser that retrieved the image
  • Previously set cookie values.

Web beacons are typically used by a third-party, such as a marketing firm, to monitor the activity of a site. A web beacon can be detected by viewing the source code of a web page and looking for any IMG tags that load from a different server than the rest of the site.

<img src="http://www.trackingfirm.com" />

Turning off the browser’s cookies will prevent web beacons from tracking the user’s activity but will still account for an anonymous visit. Several vendors, such as Google and Amazon, use this method for tracking.
Doug

Expression Web Validation Discontinuity

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

Gold as an Investment

December 9th, 2006

Owning gold has always been a hedge against rampant inflation. Gold coins have bought the passage to safety where other forms of money have failed. Many financial planners recommend owning precious metals, such as gold, as part of an overall portfolio. Consider purchasing some of the yellow metal, whether it is gold bullion or coins such as American Eagles, Krugerrands, or Maple Leafs as an adjunct to long-term financial security.

Doug

Time for 802.11n?

December 9th, 2006

I just read the N standard (802.11n which will be 10x faster than 802.11g) will not be final approved until July 2007 so anything you buy now is nonstandard and may not be able to be upgraded via firmware. Also you have to buy the corresponding receiver cards in order to have the super speed work and it may not work, either. But you get the use of faster speed until 802.11n equipment is official.

With N standard at 540MB (theoretical) and the standard Ethernet at 100MB the deciding speed factor may be your Ethernet network. GigE, which will ship with some 802.11n wireless routers, is rated at 1000MB so be sure to get GigE capability when buying an 802.11n wireless router.

If you decide get a new router/WAP (wireless access point) make sure you check for firmware upgrades right away. I bought a Linksys router/WAP and it was behind several firmware upgrades right out of the box.

Doug

Improving Wireless Laptop Access

December 2nd, 2006

Just about everyone has a laptop these days. And many users have wireless access in their home. I look at the number of access points and see I have many neighbors with them.

Note: a WAP (wireless access point) can be a separate item or built in to a router. It generally has two antennas attached to it.

One common problem is low signal strength. Many things can contribute to a low signal.
One thing to keep in mind is that a more important metric is connection speed. Laptops can perform fine if the signal strength is low but connection speed is where it should be (it depends on what wireless protocol is being used: 802.11a, 802.11b, 802.11g, 802.11n).

Here are some tips on improving your wireless laptop experience:

  • The higher the better. Place your WAP high up to maximize signal range.
  • Keep the WAP away from monitors and metal. Mine is in the center of the room and my laptop can pick it up anywhere and outside, too.
  • Get a different WAP. The older ones used the 2.4GHZ range; unfortunately microwaves and wireless telephones (not cellphones) can affect the signal. Newer router/WAPs use 5 GHZ radio waves which makes them much more immune to interference.
  • Move the WAP around because the antenna placement has a big effect on where the signal can be picked up. Even turning it a little bit can have a noticeable effect.
  • Buy a range extender such as the Linksys WRE54G

Check out Wireless Access Point Tips for setting up a WAP securely.

Doug