You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jay Smith <ja...@JaySmith.com> on 2004/12/24 06:24:08 UTC
[users@httpd] htaccess and handling filename errors
Hi,
I'm a bit new at this (at least the technical aspects), so I hope I am
asking the right questions in the right way.
My local ISP uses Apache httpd 1.3.22. I have several hundred web pages on
my site. Over the last couple of years there has been
restructuring/renaming of the paths and filenames. I use a
Mixed-Case-Dash-File-Name.html method of naming files (for readability and
search engines ranking [including my own search function]).
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?
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? A friend suggested
somehow configuring in the .htaccess to run a Perl/CGI script when file is
not found. The script would reference a file/array of correct MixedCase
filenames and their incorrect lowercase counterparts. The file/array would
be rebuilt daily. Is this a reasonable approach, or is there a better
method? How would such a script be invoked? (Please note that since the
correct filenames are MixedCase, it is not so easy to translate on the fly
from a lowercase request to a MixedCase filename -- and always get it right.)
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?
Jay
---------------------------------------------------------------------
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
Re: [users@httpd] htaccess and handling filename errors
Posted by Joshua Slive <js...@gmail.com>.
On Fri, 24 Dec 2004 00:24:08 -0500, Jay Smith <ja...@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