Forum Moderators: phranque
1) Using a RewriteMap in the config-files of apache to make use of the internal function 'tolower'.
2) Using this nasty set of 27 RewriteRules to do the job in a .htaccsess-file.
3) Using a single RewriteRule to detect malformated URLs and having them redirected to a script (php or perl or something else) which does the conversion (a single statement should do the trick) and redirects to the all lowercase URL.
Of course, option 1 is by far the best, but like many people I do not have access to the config-files. So this leaves options 2 and 3. The downside of 2 is obvious: speed. If the URL only contains only a few uppercase letters, the whole process takes a lot of time. But after a closer look, option 3 doesn't look perfect to me either: It may not be a problem with multiple uppercase letters - in fact the number of malformated letters doesen't matter in this approach - but in any case, the user gets redirected to a script, which does the actual case conversion, and then gets redirected once again to the lowercase URL.
What do I do now? I've to admit I've not that much of experience with neither Apache nor web developement at all, so I'd really appreciate any input I can get.
I haven't got the thread numbers to hand, but the site search should find them. They mostly deal with using RewriteMap if I remember rightly.
The one time I needed this conversion, I used a simple internal rewrite to a PHP script that tested the URL, and the script redirected the user to the correct URL version using two HEADER instructions.
jdMorgan has provided a lot of detail in the earlier threads.
But I just see that my description of 3 was not ideal: Instead of an external redirect, I could just use an internal rewrite, saving me one redirection. With that in mind, I think the scriptbased solution is better, is this correct?
The only thing that confuses me, is that jdMorgan uses method 2) in his "guide to fixing duplicate content & URL issues on Apache". Maybe 2 isn't so bad after all..?
Using RewriteMap means you need to have access to httpd.conf to be able to edit it; or else use a host that is prepared to set that file up how you want it. Many people can't do that.
My preference (the one time I needed it) has been the external PHP script - as it was a blindingly simple rule to select out which URL requests needed to be fed to it -- they were all requests that contained just one particular parameter.
Only in the case where a Webmaster mistakenly thinks that having that case-fixing code in place means that he/she does not have to correct uppercase-URL links on his/her own pages is this really a concern. Running that code once a day is one thing, but running it on each and every page request is another thing entirely!
Jim
What I normally have is all lower-case URLs, and if anything else is requested then it returns a 404 error. That is correct usage.
The "one time I needed it" was on a site where a mix of casing had been used in various URLs, and the site had been recently modified to only use lower-case URLs. The conversion was needed to keep all old incoming links working, and to force Google to reindex all 'incorrect' URLs.
Normally I use all lower-case URLs from Day One. If upper-case URLs are requested, they just fail with a 404 error. So, I rarely need any conversion at all.