views:

30

answers:

1

I have this rule:

RewriteRule ^(panel|admin|site)/([A-Za-z0-9]+?)/(scripts|assets)/(.*)$ Project/$2/Public/$3/$1/$4 [L]

The idea is to allow access to public assets as they exist inside modules of code. The only issue is that the naming scheme requires title case (lets assume this is unchangeable). Hence, a request to:

/site/users/scripts/myscript.js

returns 404, but:

/site/Users/scripts/myscript.js

works.

I have attempted to use mod_speling to deal with the casing issue, however mod_speling does a full redirect rather than an internal one, hence the url to the end user changes to:

/Project/Users/Public/scripts/myscript.js

Which is no good. It means that my directory structure is somewhat exposed and it means i need an extra rewrite rule to pass this through.

Is there any way of handling the capitalisation in mod_rewrite more gracefully, ie without using RewriteMap? (Need to keep everything in the .htaccess)

Alternatively, is there a way of changing mod_speling to use an internal redirect?

A: 

handling the capitalisation in mod_rewrite more gracefully, ie without using RewriteMap?

It seems to me that you could use the internal mapping function tolower, and that wouldn't need any external files. Or am I missing something?

Edit: The hacky answer is 26 rewrite rules for each of A-Z as the first letter and the substitution uses the lower case letter... Or a rule per word (like User) that can appear in the URL

Paul
For some unknown reason, you have to actually define the internal `RewriteMap` functions manually before you can use them (e.g. `RewriteMap tolower int:tolower`), which involves editing the server/virtual host configuration. Which is unfortunate, because that's definitely the best tool for the job here.
Tim Stone
Yes, this is the wall i keep running in to. :( We deploy on a wide range of servers and i dont typically have as much access as that, so i just cannot assume i have it.
devians