Multiple Parameters NGINX Rewrite

240 Views Asked by At

So I have a single file forums.php which can process both forums.php?category_id=X and forums.php?topic_id=X

When rewrite the URL to forums/category_id/X and forums/topic_id/X I can't get it to work. Nginx has some trouble understanding that there are 2 separate parameters. Here's what I have now:

rewrite  ^/forums/(.*)$  /forums.php?topic_id=$1  last;
rewrite  ^/forums/(.*)$  /forums.php?category_id=$1 last;

It's not able to get the id at the end and just returns null on the sql query... Can anyone help?

1

There are 1 best solutions below

0
On

And figured it out...

rewrite  ^/forums/topic_id/(.*)$  /forums.php?topic_id=$1  last;
rewrite  ^/forums/category_id/(.*)$  /forums.php?category_id=$1 last;