June 2009 Archives

Custom 404 for you

| 0 Comments | 0 TrackBacks
Since 6 a.m. this morning, any attempts to use a custom 404 File Not Found error for your Penn State Personal Web site for URL requests like:

  • http://www.personal.psu.edu/xyz123/badurl
will now work.  Previous to this change, they would fall through to the server-wide default 404 error page.

In contrast, requests for URLs like:

  • http://www.personal.psu.edu/users/x/y/xyz123/badurl
didn't have a problem and will continue to work.

An example of how to set a custom 404 File Not Found error page is to create the page you want visitors to see at a page like http://www.personal.psu.edu/xyz123/404error.html, then add the following line to .htaccess:

ErrorDocument 404 /xyz123/404error.html

The error page filename can be anything you want. Change the userid to match yours.

The problem was that the RewriteRules had to determine if a file or folder matching the short (trie-less) URL belonged to a userid that matched the pattern.  It did this through a "does the file exist?" (-f) test.  This would prevent mismatches for hits that should be local to the DocumentRoot such as /users/i/m/images/lion.gif.  However, this precluded the ability for a user to use a custom 404 error for the the short URL version of their space.  The new way performs a folder exists (-d) RewriteCond test on the user's home folder, allowing that user to claim any URL requests for that space (custom 404 or not).  Prior to Feb 21, 2006, this was never a problem, since we used to force an external [R] redirect before the 404 condition would be reconsiled.

In retrospect, I am tempted to declare my old RewriteRules for www.personal.psu.edu sloppy, since there were other inefficiencies corrected this morning, but I guess such judgment comes with experience using them.  They certainly are "D*** cool voodoo".

Search This Blog

Full Text  Tag