开发者

mod_speling internal redirect, or how to handle caps with mod_rewrite

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜