[nylug-talk] IIS/Windows to Apache/Linux conversion problems (case insensitivity)
Peter C. Norton
spacey-nylug at lenin.net
Wed Jul 11 18:16:24 EDT 2007
On Wed, Jul 11, 2007 at 05:27:52PM -0400, Chandhee Thala wrote:
> hello,
>
> We have a site with URLs that looks like this:
>
> http://example.com/Dir1/File.jpg
> http://example.com/Dir2/File000.jpg
> http://example.com/Dir2/File001.jpg
>
> The problem was that this site was running on IIS, so people referred to
> the above URLs like this:
>
> http://example.com/dir1/file.jpg
> http://example.com/Dir2/file000.jpg
> http://example.com/Dir2/File001.JPG
>
> Which wasn't really a problem because Windows is case-insensitive. I
> guess IIS or Windows folded everything.
>
> So now we moved the site to Apache on Linux, and so the URLS that refer
> to the code with the wrong case are not working.
>
> I think we have two options here:
>
> Option 1:
>
> Fix all references in HTML/code that refer to this URLs. If it
> was pure HTML, I'm sure a find+grep+sed on the pages would fix
> it, but a) there are about 300k references to these URLS and b)
> a lot of these references are in compiled web code that we would
> have to fix the sources for and recompile.
>
> Option 2:
>
> In the Apache conf file put in a mod speling or rewrite (not
> sure which one is more appropriate for the task) directive that
> folds the case for every request. I'm certain this is doable
> (though I don't know how), but the only concern that I have is
> that this would put significant load on what is supposed to be a
> static images server.
>
> Any thoughts?
If you have such strict control over the naming of the files and
directories, then mod_rewrite is the lower-cost answer. It doesn't
require a directory scan per request, which mod_speling's
documentation implies it does. All you need is a regular expression to
rewrite the regular expression "/([A-Za-z)(.*)" with the proper case,
right?
So something like:
RewriteMap lowercase int:tolower
RewriteMap uppercase int:toupper
RewriteRule /([A-Za-z])(.*)/${uppercase:$1}${lowercase:$2}
should work with a very minimal overhead. I'm not sure about the
"greediness" of the regular expression above, so it need to be tested.
-Peter
--
The 5 year plan:
In five years we'll make up another plan.
Or just re-use this one.
More information about the nylug-talk
mailing list