1

The actual URL's are like - /category.php?id=2 and /product.php?id=56 . I applied the following rules in my htaccess file -

RewriteEngine On
RewriteRule   ^.+/p/([0-9]+)   product.php?id=$1    [NC,L]
RewriteRule   ^.+/c/([0-9]+)   category.php?id=$1    [NC,L]

And i am getting the following url patterns -

/c/2 and `/p/56` 

Upto this it is fine Previously i could get the ID's of category and product from like ?id= 2 by GET method. But get method will not work after rewrite. How can i get the ID's also the page type (category,products)?

Waldi
  • 39,242
  • 6
  • 30
  • 78
Tanjima Tani
  • 580
  • 4
  • 18

1 Answers1

1

Try this

RewriteEngine On
RewriteRule   ^.+/p/([0-9]+)   product.php?id=$1    [QSA,L]
RewriteRule   ^.+/c/([0-9]+)   category.php?id=$1    [QSA,L]

QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite.

L means if the rule matches, don't process any more RewriteRules below this one.