FocalGuy:
I haven't tried to do what you are doing, so let me comment on your settings and tell what I would pursue (sorry).
The RewriteCond's that follow your rewrite rule have no effect. If you want them to apply to the rewrite rule, they need to come before it.
I think trying to get all of this into a singular set of rewrite rules and conditions would be a real headache.
You might want to set up a couple of sets of conditions and or rules.
For example, if you want everything in your '/gallery/' directory to go there and not be rewritten, set up a ruleset just for that. Maybe:
RewriteRule ^gallery/ - [L]
It would have to come before the ruleset for your Joomla. This should (i haven't tested it) do a couple of things, keep the request_filename the same as it was recieved ( '-' means don't rewrite), then not process anymore rulesets (the [L] means last ruleset for this match).
The problem is going to be mixing it up with a broader ruleset like (.*). This means the rule applies to everything.
mod_rewrite builds a table of rewrite rules and conditions that is indexed by the pattern you set in the RewriteRule. RewriteRule (.*) means that RewriteRule applies to everything.
I think you could get away with it, if the RewriteRule I suggested above is put in before the (.*) rule. But you will have to try it and see. It also might give you a 500 server error.
You don't have to have any RewriteConds for a RewriteRule to work. But sometimes you can't get all the conditions into a simple RewriteRule.
You might get away with this:
Code: Select all
RewriteRule ^images/(.*) - [NC,L]
RewriteRule ^forum/(.*) - [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /cms/%1
Then put the normal .htaccess for SEF in the root of cms if you are using SEF.
Anything in square brackets following a RewriteRule or RewriteCond is command flag, and in the case of multiple, they are seperated by ',' (commas). NC means case insensitive, L means this is the last rule if the pattern matches. The %1 in the last Rewrite rule tells it to use whatever matched the (.*) .
RewriteCond's can match against Apache variables (like REQUEST_URI), RewriteRules match against the singular Apache variable REQUEST_FILENAME, which unfortunately can change if a rule before the one it is currently in has matched already.
I would suggest you take a little time and read up on how this works. The documentation can be a little frustrating, as it doesn't cover all supported or unsuported aspects of the regex engine apache uses, and does not tell you what server directives set in the http.conf can cause you to get 500 server errors, but at least it is a guide to how to use this mod_rewrite.
Documentation is here:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
Feel free to ask questions if you think I can help, but by the time you get it all working, I may be asking you questions (about rewriting a root to a directory).
GRAM