Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help with mod_rewrite

My current code is

RewriteRule ^(.*)$ index.php?pg=$1 [L,QSA]

index.php?action=product shop.com/product
index.php?action=product/add shop.com/product/add

Now I want to add paging to some of the pages, something like

index.php?action=product&page=1&show=20 shop.com/product/1/20
index.php?action=product/add&page=1&show=20 shop.com/product/add/1/20

How do I do this?

like image 339
Stasa Avatar asked Mar 22 '26 19:03

Stasa


1 Answers

RewriteEngine On

RewriteRule ^product$ index.php?action=product
RewriteRule ^product/add$ index.php?action=product/add
RewriteRule ^product/(\d+)/(\d+)$ index.php?action=product&page=$1&show=$2
RewriteRule ^product/add/(\d+)/(\d+)$ index.php?action=product/add&page=$1&show=$2


I suggest taking a look at this answer too. I think it would be better in this case.

like image 74
Michiel Pater Avatar answered Mar 24 '26 10:03

Michiel Pater



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!