3

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

1. The first:

https://example.com/folder/myfile.php?id=xx&param1=yy

I want to rewrite to:

https://example.com/folder/myfile/xx/yy

2. The second:

https://example.com/another-folder/myfile.php?id=xx&param1=yy

I want it rewrite to:

https://example.com/myfile/xx/yy

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

1 Answer 1

-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.