httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <jsl...@gmail.com>
Subject Re: [users@httpd] htaccess and handling filename errors
Date Fri, 24 Dec 2004 21:54:00 GMT
On Fri, 24 Dec 2004 00:24:08 -0500, Jay Smith <jay@jaysmith.com> wrote:
> I use .htaccess for both "options", etc., and "Redirects".  I understand
> that using .htaccess results in a performance hit, but this is a very low
> volume site.
> 
> 1) The .htaccess contains *hundreds* of Redirects due to the filename
> changes (a lot of people have and still use those old filenames) and that
> makes for a very large & resource-consuming .htaccess file.  That does
> concern me.  QUESTION: Is there a method by which the *Redirects* can be
> put in a different file which is called upon *only* when Apache can't find
> the filename it is looking for?

Several methods -- none of them particularly pretty.

1. Check mod_asis.  You can put an .asis file in place of the old file
that contains a Location: header pointing to the new URL.  This sends
a proper redirect.

2. Replace your html files with a small file that contains a <meta
refresh> tag.  I don't particularly recommend this, because it doesn't
send a proper HTTP redirect.  But it will probably work.

3. Use an ErrorDocument 404 directive that points at a CGI script that
looks at the URL, figures out the proper location, and sends the
appropriate Location: header.  This is probably the cleanest (doesn't
require lots of old files hanging around), but requires a little
configuration.


> 
> 2) In my error logs I am seeing a lot of file-not-found errors (I thought
> they should be 404, but they are showing as 302) because apparently some
> browsers and some robots are looking for the "correct" filenames but for
> unknown reasons, they are looking for all lowercase letters -- but the
> correct filenames are (and always have been) actually MixedCase.  QUESTION:
> What is the best method of getting Apache to find the correct file when the
> browser/robot is asking for it in the wrong case?

Ask your ISP if you can use mod_speling (part of the standard apache
distribution).  It fixes this problem quite easily.

> 3) As I mentioned, the ISP's configuration (or my .htaccess?) is giving 302
> errors instead of 404 errors when a file is not found.  The *only* 404 I
> find in the log for the last three months some hackers attempt to do a
> POST. All the GETs throw 302 when the file is not found. My .htaccess has:
> ErrorDocument 404 http://www.JaySmith.com/error404.html
> When it throws a 302 error, it is doing so for a filename that simply does
> not (and often never did) exist.  QUESTION: Is this a "real" problem? Is it
> likely caused by something I have done or the ISP's Apache configuration?

Try replacing the full URL in the ErrorDocument directive with simply
/error404.html (assuming that file is on the same site).  This should
give a true 404.  Is this a "real" problem?  Probably not, but it
doesn't hurt to get it right.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message