Nginx Rewrite file downloads

Posted May 28, 2021 166 views

i use apache server its working fine with these rewrite rule now i transfer to nginx server i try these rewrite code

    server {
    root /home/userfile/public_html/;
    location /dld {
    rewrite ^/dld/(\w+)/(\w+)/(.*)/?$ /download.php?p=$1&st=$2&fn=$3 last;

its give me wrong file size download like in KB.
show these error in file

    2021/05/28 05:47:12 [notice] 24755#0: *1 rewritten data: "/download.php", args: "p=2427&st=UJyN3Kou6cbhsZAxEHzhHtJ45un4Puco&", client:, server:, request: "GET /dld/2427/UJyN3Kou6cbhsZAxEHzhHtJ45un4Puco/ HTTP/1.1", host: ""

    2021/05/28 05:47:12 [notice] 24755#0: *1 "^/dld/(\w+)/(\w+)/(.*)/?$" matches "/dld/2427/UJyN3Kou6cbhsZAxEHzhHtJ45un4Puco/", client:, server:, request: "GET /dwnld/2427/UJyN3Kou6cbhsZAxEHzhHtJ45un4Puco/ HTTP/1.1", host: "

please give me any solution for solve it second our files and folder in public_html
Download.php for download code file
Softs folder for file location.
and its working fine on apache server with same httaccess rules

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!