that should rewrites links that start with site.com/news/ OR Info/ and could have up to three other cat after them, but are not mandatory after news or info and can be only 1 2 or 3 and could end with a / or without.
This works it seems. the problem is that if I put More than three cat doesn't give a 404 error! I want that once it gets a forth element (news/cat1/cat2/cat3/cat4 <- not allowed) it won't rewrite! Is it possible?
Msg#: 4098111 posted 6:14 pm on Mar 15, 2010 (gmt 0)
Add the [L] flag to the end of the rule.
Adding a $ end anchor to the pattern will force three or less.
There's a potential problem when only one element is present. Will it match the first pattern or the last pattern? Will it do that on all servers, and Apache versions? Could it change after a server upgrade?
Another problem comes from the * in the [a-z-]* pattern, and the optional slashes mid-URL. A request like example.com/something[b]//[/b]something is perfectly valid (but highly undesirable) with your rules.
I think I would use three rules, with one, two and three fixed patterns.
Don't make the trailing slash optional. Either require it, or require that it be omitted, otherwise you're introducing yet more Duplicate Content issues.
Msg#: 4098111 posted 3:19 pm on Mar 16, 2010 (gmt 0)
The [L] flag ends mod_rewrite processing if the rule is invoked.
Since it is unlikely that you would want your server to have to test all of the following rules after matching and invoking a particular rule, this is a question of efficiency. The best way to avoid prematurely-required server upgrades is to avoid wasting CPU cycles, so the [L] flag is almost always a good idea. By the time you need code that you wouldn't want to use the [L] flag on, you'll know why you don't want to use it, as it's generally only not wanted for certain "advanced" coding techniques.