I'm trying to set up nginx rewrites; I have it successfully set up to remove the extension:
https://example.com/accounts?id=user-123
points to https://example.com/accounts.php?id=user-123
using just try_files:
location / { try_files $uri $uri/ $uri.html $uri.php?$args; }
I want to set up a second rewrite that goes before that; all the user IDs start with user-
, so example.com/user-sdgas3
should rewrite to example.com/accounts?id=user-sdgas3
, example.com/faq-abc8989as
should rewrite to example.com/faqpage?id=faq-abc8989as
, example.com/faq-abc8989as?view=true
goes to example.com/faqpage?id=faq-abc8989as&view=true
etc.
What I tried was just adding variations of this to the very beginning for each URL extension:
location ^/faq-(*)$ { try_files $faqpage?id=$1; }
with no luck. How could this be done?