i have a problem to rewrite 2 parameters that are on the same place in a URL.
i want the following URL Structure:
category (No page or letetr is set)
category/page-2 (different page from page 1)
category/e/page-2 (letter and page is set)
The problem is that my second rule is ignored. 🙁
Here is my code:
RewriteRule ([^/.]+)/([^/.]+)$ index.php?cat=$1&letter=$2 [L,NC]
RewriteRule ([^/.]+)/page-([^/.]+)$ index.php?cat=$1&page=$2 [L,NC]
RewriteRule ^([^/.]+)$ index.php?cat=$1 [L,NC]
Your second rule isn’t being ignored. Instead, anything that matches the second rule will also match the first rule, so the first rule is processed instead (and the
[L]modifier prevents further processing).Basically, the second rule is the same as the first, but with the additional condition that the characters
page-must also exist between the two captured sections. Thispage-portion matches the([^/.]+)condition of the first rule, so it will be matched when the firstRewriteRuleis processed.Try reversing the order of the first two rules.