[Apache] Rewrite Help

Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
I'm working on a site that needs to catch some old search engine referrals and inbounds in its new structure. The rule I'm using is the last in a set of rewrites that stop processing if they match - using the L flag:

To illustrate, /john/doe or /john/ needs to be rewritten to /aaa/bbb/john. Trailing slashes optional.

Code:
RewriteRule ^/([^/]+)/?([^/\.]+)?/?$       /aaa/bbb/$1     [NC,R=301,L]
The URL redirected to is caught earlier on; it won't loop. So that rule is only ever run if an earlier rule does not e.g. a rewrite rule for /news/2006/april => /news.php?y=2006&m=4 would be caught first.

The problem is that I have, is that there are some 'real' directories that I don't want to match in this rule. I don't want /css/foo to be rewritten to /aaa/bbb/foo or /javascript/foobar to be rewritten to /aaa/bbb/foobar. /css/style.css wouldn't be rewritten as I haven't rewritten anything with a dot in it as above.

So, eventually getting round to my question, how can I avoid including/blacklist my real directories from that rule without having to add a separate catch rule for each one?

TIA :).
 
Back
Top Bottom