[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

mod_rewrite conditions and rules

Posted on 2006-04-06
2
Medium Priority
?
482 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:Mr_Nil
2 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 1000 total points
ID: 16394614
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
 
LVL 10

Author Comment

by:Mr_Nil
ID: 16398305
> 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

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses
Course of the Month20 days, left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question