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 (let’s 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?

unor
  • 92,415
  • 26
  • 211
  • 360
jhogendorn
  • 5,931
  • 3
  • 26
  • 35

1 Answers1

0

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

The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134
  • 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 Sep 06 '10 at 17:28
  • 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. – jhogendorn Sep 07 '10 at 00:50
  • I'm going to mark this as the correct answer, its not really 'right' as in answering the criteria of the question, but since thats impossible, this is as close as it gets :) – jhogendorn Mar 10 '11 at 23:09