Sample Header Ad - 728x90

Rewrite rule doesn't work in NGINX

3 votes
1 answer
1204 views
Consider a URL as shown below: http://myDomain.tld/anAddress/myFile.pdf?X=zzz&Y=kkk How can I have it as : http://myDomain.tld/anAddress/myFile.pdf/zzz/kkk I want to get rid of both ?X and &Y. I'd be glad if someone let me know what rule I should use. **MY SERVER BLOCK :** server { listen 80; server_name _; location / { root /my/root/path; rewrite ^/(.*)pdf/(.*)/(.*)$ /$1?md5=$2&expires=$3 break; secure_link $arg_md5,$arg_expires; autoindex on; secure_link_md5 "$secure_link_expires$uri aWord"; if ($secure_link = "") { return 403; } if ($secure_link = "0") { return 410; } } } --------------------------------------------------------------------------- **Purpose :** To be more precise, my URL is like: http://myDomain.tld/anAddress/myFile.pdf?md5=So1Me2Ha3Sh4&expires=123456789 I want it to be like: http://myDomain.tld/anAddress/myFile.pdf/So1Me2Ha3Sh4/123456789 In **Apache**, we can use: RewriteRule ^(.*)pdf/(.*)/(.*)$ $1?md5=$2&expires=$3 When I tried to convert it to NGINX form, it became: rewrite ^/(.*)pdf/(.*)/(.*)$ /$1?md5=$2&expires=$3 break; But it didn't work.
Asked by Parsa Samet (777 rep)
Jan 8, 2017, 01:34 PM
Last activity: Sep 19, 2020, 03:28 PM