Forum Moderators: phranque
i have some web pages whose file names are something like
[site.com...]
and I want the page to be served up if someone types
[site.com...] - - essentially, I want
the server to ignore case.
i think the answer has something to do with mod_rewrite, but
so far, i've only found the ability to hard-code all A's to a.
or the mod_speling which only looks for one mistype.
If you know of the fix for this, I'd appreciate it. Or if you can point me in the direction of a creative solution, also obliged.
Thank you
Welcome to WebmasterWorld [webmasterworld.com]!
If you have access to httpd.conf, you can use RewriteMap to do a tolower on all URLs. Unfortunately, this capability is not available in per-directory .htaccess context, so therefore the interest in the one-by-one substitution that you found.
Jim
"Not available in per-directory context" means not available in .htaccess.
See the RewriteMap description in the mod_rewrite documentation for an example of a tolower call.
Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]
If you cannot change your site to use all-lowercase (or all-uppercase) links and filenames, then an alternative would be to to use a tolower RewriteMap first, and then create a second RewriteMap that maps the resulting all-lowercase URLs to your mixed-case URLs. This would require a map entry for each existing URL, but would prevent the huge problem of having to handle all possible case-mixing variants of your URLs. Then going forward, use all-lowercase links and URLs so that this problem does not grow. In order to avoid running the RewriteMap for every requested URL, you could then preface the ruleset with
RewriteCond %{REQUEST_URI} [A-Z]
Jim