RegEx construction to exclude files
I'm really stuck with creating an RegEx that excludes files from being rewritten.
I am using Cherokee as web server and want to turn links like http: //example.com/123 to http: //example.com/get.php?short=123.
My problem is that I want to create a switch for files and no files.
/([^.]+) => /get.php?short=$1
/([.]+) => /$1
I guess the second excludes the first somehow but I am unable to find out.
How to fix this or is the开发者_运维问答re a better solution?
Paul
You'd have to add a higher priority rule in the same Virtual Server behavior rule, with a 'File Exists' match. Most likely you want it to use the 'Static Content' handler.
In that way, when the behavior rule is evaluated, the static file will be matched against that rule (and sent). Whenever the request does not target a static file will continue to be evaluated against the rest the behavior list where your regex rule is placed.
Even though it is different to what some people are still used to, Cherokee's behavior list are much more intuitive and powerful that in counterpart on Apache (where everything is defined together with a bunch of one character parameters).
You probably want:
RewriteCond -f
精彩评论