Question

Nginx Rewrite file downloads

Posted May 28, 2021 55 views
Nginx

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

    server {
    server_name dl.example.com;
    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&fn=ShareMePC.zip", client: 172.69.39.7, server: dl.example.com, request: "GET /dld/2427/UJyN3Kou6cbhsZAxEHzhHtJ45un4Puco/ShPC.zip HTTP/1.1", host: "dl.example.com"

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

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!