case insensitive redirects?

D

Denise

Hi,

I have a website where a number of the pages are named after people
(authors, actually).
For example, http://example.com/name.html

However, sometimes folks looking for those pages, type in the capitalized
name:
http://example.com/Name.html , which results in a 404.

I also have a directory called something like http://example.com/ABCD/
and often folks type in http://example.com/abcd instead, which also results
in a 404.

Is there any rule I can add to my .htaccess file (short of redirecting each
page individually) to make these pages / directories case insensitive?

Thanks so much!
Denise
 
J

Jukka K. Korpela

Denise said:
Is there any rule I can add to my .htaccess file (short of
redirecting each page individually) to make these pages / directories
case insensitive?

I've got the impression that you might be able to do that in the global
configuration of the server, httpd.config file (not .htaccess), using
RewriteMap. I must admit that the Apache documentation on this is somewhat
obscure to me.
 
D

Denise

Alan J. Flavell said:
Assuming Apache-based server -

The easy way is to activate mod_speling

Thanks Alan, for the great suggestion!

Yes, it is indeed an Apache server, using version 1.3.37.

I Googled "mod_speling" and found a page about it that says the directive to
use is:
CheckSpelling on

However, I inserted that in my .htaccess and got a 500 Interal Server error.
Apparently it isn't able to work on my site, but I don't know why. I'll try
to investigate further.

all best,
Denise
 
D

Denise

Jukka K. Korpela said:
I've got the impression that you might be able to do that in the global
configuration of the server, httpd.config file (not .htaccess), using
RewriteMap. I must admit that the Apache documentation on this is somewhat
obscure to me.
Hi Jukka,

Thanks for your suggestion. I'll look into it, but I think I don't have
access to the httpd.config file.

best,
Denise
 
A

Alan J. Flavell

I Googled "mod_speling"

Go directly to the Apache documentation - it won't bite ;-)

In this case - http://httpd.apache.org/docs/1.3/mod/mod_speling.html
and found a page about it that says the directive to
use is:
CheckSpelling on
true

However, I inserted that in my .htaccess and got a 500 Interal
Server error.

oops. Well, the server's error log should show why it complained. If
you don't get access to the error log then debugging is much harder -
do you get any support from the service provider for this kind of
issue?

good luck, anyway
 
D

Denise

Alan J. Flavell said:
Go directly to the Apache documentation - it won't bite ;-)

In this case - http://httpd.apache.org/docs/1.3/mod/mod_speling.html


oops. Well, the server's error log should show why it complained. If
you don't get access to the error log then debugging is much harder -
do you get any support from the service provider for this kind of
issue?

good luck, anyway

Hi Alan,

The error log says,
"Invalid command 'CheckSpelling', perhaps mis-spelled or defined by a module
not included in the server configuration"

I'm sure my host could shine some light on that.

Don't know what I will do next. I've just been reading online some opinions
that the CheckSpelling directive is rather a security risk. All I really
want to do is have it check the case, which wouldn't involve any security
problems, but it seems that's not possible. So I'm going to have to think
things over.

best,
Denise
 
A

Alan J. Flavell

Don't know what I will do next. I've just been reading online some
opinions that the CheckSpelling directive is rather a security risk.

That's a bit of a vague remark, but maybe it's referring to the effect
described here in the Apache documentation:

* the document trees should not contain sensitive files which could
be matched inadvertently by a spelling "correction".

Provided that you only upload to the server, files that you want to
make public, then this isn't really a problem. If you try to "hide"
some files by keeping their names a secret, then mod_speling might
expose them, I guess that's obvious, no?
All I really want to do is have it check the case, which wouldn't
involve any security problems, but it seems that's not possible.

Here's another possibility. If you take a look at
http://httpd.apache.org/docs/2.0/platform/windows.html#cust , then
there is, amongst other things, a recipe (third bullet point) which
will force all URLs to lower case. It uses mod_rewrite - but if your
provider has excluded mod_speling then it's on the cards that they
would have excluded mod_rewrite also. But it might be worth a try.

(don't be confused that the recipe is given for the Win32 context - it
looks equally usable in unix-ish contexts too). (Not actually tested
in practice, I admit).

Another alternative is to provide a custom 404 script which fixes-up
the kind of error you're talking about. But that would be a whole new
discussion theme...

good luck
 
D

Denise

-
Alan J. Flavell said:
Here's another possibility. If you take a look at
http://httpd.apache.org/docs/2.0/platform/windows.html#cust , then
there is, amongst other things, a recipe (third bullet point) which
will force all URLs to lower case.
(don't be confused that the recipe is given for the Win32 context - it
looks equally usable in unix-ish contexts too). (Not actually tested
in practice, I admit).

I'll take a look at it, thanks for the idea.
It uses mod_rewrite - but if your
provider has excluded mod_speling then it's on the cards that they
would have excluded mod_rewrite also. But it might be worth a try.

Mod_rewrite works fine.
Another alternative is to provide a custom 404 script which fixes-up
the kind of error you're talking about. But that would be a whole new
discussion theme...

Yeah, I don't want to go that route.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top