APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > Websites, Blogging > Eliminate 404 errors for title_files
Printer Friendly Version




Eliminate 404 errors for title_files



You may have been redirected here beause you are using a very old browser. This page explains what your browser was trying to do and why it isn't right.

For a long, long time now I've been seeing strange 404 errors in my logs and I simply could not imagine what was causing them. The symptoms were always the same: someone would read a page, and then they'd try to read a page that was constructed from the page title (the text actually between the <title> </title>tags). I'd see something like this in my logs:


202.79.26.154 - - [10/Dec/2007:11:14:47 +0000] "GET
/Basics/Permissions_files/nslate.css HTTP/1.1" 404 6823
"http://aplawrence.com/Basics/perms.html" "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"

202.79.26.154 - - [10/Dec/2007:11:14:47 +0000] "GET
/Basics/Permissions_files/reset-fonts-grids.css HTTP/1.1" 404 6832
"http://aplawrence.com/Basics/perms.html" "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
 

and my error log would have:

[Mon Dec 10 11:14:47 2007] [error] [client 202.79.26.154] File does
not exist:
/usr/local/www/vhosts/vps.pcunix.com/htdocs/Basics/Permissions_files,
referer: http://aplawrence.com/Basics/perms.html
 

I hate error log entries. Simply cannot stand 'em. Yes, some are unavoidable: if someone out in the netosphere mistypes a link to my site, I'm going to have a log entry. OK, I can live with that. but these aren't mistypes. These are somebody's programming error - maybe mine, maybe someone else, but whatever it is, I need to understand it and fix it if I can.

At first, I thought it had to be me. There's a lot of behind the scenes Perl and Javascript that creates these pages, and I wrote all of it, so maybe I screwed up somewhere: maybe I accidentally created these as very broken links somewhere. I pored through my code, I ran all kinds of automated tests, but I could not find a smoking gun anywhere.

Last night when I went to bed I told myself that I would solve this annoying problem the next day no matter what. So this morning I got up early and started looking at log files again. Was there any pattern to these errors that might give me a clue?












Why yes there was: every one of these had "MSIE 6.0" in the browser field. And that's when I finally noticed that every one of them also had appended "_files" to the title tag. Duh! When do you see "_files"? When you download a file, saving it locally!

Of course! These come from people saving the web page to their own machines, and IE 6.0 apparently has some stupid broken code (yay Microsoft - again!) that screws up and causes these errors.

Okey dokey. Mystery solved, it's Microsoft Internet Explorer 6.0 that is filling up my error logs. I guess it surprises me a little how many people are saving local copies, but mostly I just want to fix the error. Since I can't make them upgrade their browsers, I need to rewrite their requests, so that's a job for .htaccess (see using .htaccess files to redirect pages). But what am I going to do with the requests? I'm afraid to redirect them to any normal page for fear they'll get into a loop. So instead, I created a file called "safedown.html" which only contains this:

<html><head>
</head>
<body>
You need to upgrade your browser
</body></html>
 

Then, in /.htaccess, I added these lines:

RedirectMatch permanent  .*_files$ /safedown.html
RedirectMatch permanent  .*_files.*css$ /safedown.html

The first line probably isn't necessary.. I think the actual source of this is IE misinterpreting "@import" lines, but I added it just in case. I could leave off the trailing $, but unfortunately i have legitimate files with "_file" as part of their name.

That fix should eliminates errors from my logs, and coincidentally gives me an easy way to count how many local file saves happen just by counting "safedown.html". It shouldn't affect their download in any way - they'll probably never even look at the file I sent them to.

Make sure to read the comments as there may be other ways to fix this.


If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

5 comments




More Articles by Anthony Lawrence - Find me on Google+



Click here to add your comments





Mon Dec 10 15:46:57 2007:   BigDumbDinosaur


<head>
</head>
<body>
You need to upgrade your browser
</body>


I would have worded it "You need to replace your browser with one that adheres to published standards." <Grin>



Mon Dec 10 15:53:45 2007:   TonyLawrence

gravatar
They might just assume that anything Microsoft does *is* the standard :-)



Mon Dec 10 16:11:51 2007:   TonyLawrence

gravatar
By the way, a post at http://www.webmasterworld.com/css/3524102.htm
says that my redirect won't work and instead suggests this


# Fix up broken MSIE 6 "Save page as" .css path requests
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows
RewriteRule _files/([^/]+/)*([^.]+\.css)$ /$2 [L]



Mon Dec 10 16:25:46 2007:   TonyLawrence

gravatar
I also noticed this.
I have:

@import "/reset-fonts-grids.css";
@import "/nslate.css";
@import url( http://www.google.com/cse/api/branding.css);

And now I see in my logs that IE has never screwed up with "branding.css", so maybe that is another way to fix it..



Sat Oct 18 21:20:33 2008:   TonyLawrence

gravatar
Also see http://aplawrence.com/Web/google-adds-source-links.html for more on 404 pages and their causes.

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



LOD Communications, Inc.

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!


book graphic unix and linux troubleshooting guide




 I sell and support
 Kerio Mail server
pavatar.jpg

This post tagged:

       - Web/HTML




Unix/Linux Consultants

Skills Tests

Guest Post Here