Answer the question
In order to leave comments, you need to log in
Problem with RewriteRule in htaccess?
Friends, please tell me how to correctly compose RewriteRule so that everything works correctly.
There is a rule:
RewriteRule ^katalog/([a-z0-9-]+)(/([a-z0-9-]+))?(/page-(\d+))?/$ /category.php?cat1=$1&cat2=$3&page=$5 [L,QSA]
Answer the question
In order to leave comments, you need to log in
By default, quantifiers ? * +
are greedy.
By adding ?
them, you can switch to lazy mode?? *? +?
RewriteRule ^katalog/([a-z0-9-]+)(/([a-z0-9-]+))??(/page-(\d+))?/$ /category.php?cat1=$1&cat2=$3&page=$5 [L,QSA]
( а | b )
alternatives are evaluated from left to right. (/([a-z0-9-]+))??
can replace(|/([a-z0-9-]+))
RewriteRule ^katalog/([a-z0-9-]+)(|/([a-z0-9-]+))(/page-(\d+))?/$ /category.php?cat1=$1&cat2=$3&page=$5 [L,QSA]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question