I have two types of URL and want to rewrite it for friendly URL.

1. The first:


I want to rewrite to:


2. The second:


I want it rewrite to:


Please help me how to do it. I've searched Google but I do not understand the principle rewrite.

1 Answer 1


Try something like this in your location / { } block:

try_files $uri $uri/ /myfile.php?$args =404;
rewrite ^/folder/myfile/(.*)$ /folder/myfile.php?id=$1&param1=$2;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.