mod rewrite - .htaccess for identical url -
i have url
http://localhost/sahara/product.php?action=viewcat http://localhost/sahara/product.php?action=viewsubcat&catparent=40
and htaccess
rewriterule product-action-(.*)\.html$ product.php?action=$1 rewriterule product-action-(.*)-catparent-(.*)\.html$ product.php?action=$1&catparent=$2
then when call rewrite url, first code work
http://localhost/sahara/product-action-viewcat.html ---> it's work http://localhost/sahara/product-action-viewsubcat-catparent-40.html ---> it's not work
what correct code htaccess script thanks
this because uri /sahara/product-action-viewsubcat-catparent-40.html
matches first pattern: product-action-(.*)\.html$
. (.*)
part of regular expression, matches everything, matching viewsubcat-catparent-40
part of uri.
you either need make expression more restrictive, or change order of 2 rules:
more restrictive (something this):
rewriterule product-action-([a-z]+)\.html$ product.php?action=$1 [l] rewriterule product-action-([a-z]+)-catparent-([0-9]+)\.html$ product.php?action=$1&catparent=$2 [l]
or reverse order:
rewriterule product-action-(.*)-catparent-(.*)\.html$ product.php?action=$1&catparent=$2 rewriterule product-action-(.*)\.html$ product.php?action=$1
Comments
Post a Comment