mod_rewrite conditions and rules

I'm trying to adjust a rewrite condition and rule so that in a particular situation the rule is not performed.  

Basically, the application I am working on has a rewrite that when the file is not found pushes the request_uri string into a page to work out what needs to be done.  This works great except that I have 2 exceptions to this rule.  The first is the path "/CFFormGateway" and the second is "/flashservices/gateway".  Neither of these exist, but I don't want to redirect when these paths are accessed, as they are handled by the application server (CFMX 7), rather than the web server.

I've tried a few variations, but I've either broken the redirection completely or not had any affect, so I thought I would see if anyone could help me out.

The rewrite I currently have in a .htaccess file is this :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{1}.*)?$ redirect.cfm?thisURI=%{REQUEST_URI} [QSA,L]

This will rewrite any 'not found' lowercase URIs into redirect.cfm, which means that /CFFormGateway will be ignored, but /flashservices/gateway is not ignored and is pushed to redirect.cfm, breaking my flash remoting.  How can I change this rewrite to stop this from happening?  

TIA

Mr Nil
LVL 10
Mr_NilAsked:
Who is Participating?
 
caterham_wwwCommented:
Use a cond. checking the value of request_uri

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(CFFormGateway|flashservices/gateway)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{1}.*)?$ redirect.cfm?thisURI=%{REQUEST_URI} [QSA,L]


> This will rewrite any 'not found' lowercase URIs

no. Only, if the first char assuming /abc -> a is lowercase, the rewrite would take place. /aBcD would be substituted with redirect.cfm, too.
If you're looking for a complete lowercase match, use as RegEx

^[a-z/]+$
instead.
0
 
Mr_NilAuthor Commented:
> no. Only, if the first char assuming /abc -> a is lowercase, the rewrite would take place. /aBcD would be substituted with redirect.cfm, too.
> If you're looking for a complete lowercase match, use as RegEx

You're quite right.  The client is using camelCasing as part of their development standards, so this allows for any links that have been created using camel case.

Thanks for the rewritecond above - that worked perfectly. Bizarrely, I have already tried something similar, but was getting an error.  Not really sure what I did differently.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.