Jul 10, 2008 at 7:44 PM
Edited Jul 10, 2008 at 7:45 PM
YES, what you are doing makes sense.
The rules are evaluated in a sort of waterfall, so if you can handle the more common URLs in the rules defined earlier in your INI file, then you will have better performance and efficiency in the operation of the filter.
The rule you have...
RewriteRule ^/admin/(.*)$ /admin/$1 [I,L]
...Will rewrite any URL that comes in, with /admin as a first segment in it. It will rewrite it to exactly the same URL.
You know that the filter recurses: the output of a rule is then passed through the ruleset again. But you've stopped that with the [L] flag.
If you also want to ignore certain files, or files with particular extensions, then you can do something like this:
RewriteRule ^/(.+\.(css|jpg|js|gif))$ /$1 [I,L]
This will fire on any URL that ends with .css or .jpg or .gif. It fires on URL requests such as:
Keep in mind it will also fire on URL requests in which the query string ends in a pattern, such as these:
If you want to avoid THAT, then you need to filter out the question mark, such as with:
RewriteRule ^/([^\?]+\.(css|jpg|js|gif))$ /$1 [I,L]
This says, any path that has no question mark, and ends in a .css .jpg .js or .gif, should be rewritten to itself and then STOP.