Anyone tell me how to rewrite URL in Nginx
https://dl.expamledomain.com/download.php?p=524&st=mmmnGreUwmpRTGl7RO9NtGLhgQZrQ1IW&fn=file.zip
to
https://dl.expamledomain.com/dwn/524/mmmnGreUwmpRTGl7RO9NtGLhgQZrQ1IW/file.zip
second our download.php file in the root public_html folder.
I have used this rule on .htaccess
RewriteEngine On
RewriteRule ^dl/(\w+)/(\w+)/(.*)/?$ download.php?pt=$1&tk=$2&flen=$3 [L,QSA,NC]
its working fine but I try many on Nginx rule like this
I try this code in Nginx but not working
http{
server {
listen 80;
server_name *.oursitename.com;
location / {
rewrite ^(?i)/dl/(\w+)/(\w+)/(.*)/?$ /download.php?pt=$1&tk=$2&flen=$3 last;
}
location = /download.php {
# Your fastcgi_pass configuration
}
}
its show me this error
" open() "/home/username/public_html/dl/515/25xfkUNYOGvvOt0z7ko9YkpHCWZrlRfX/file72.exe" failed (2: No such file or directory),"
our file location like this
1.Home
1.Username
1.public_html
1.downloadfolder
2.download.php
3.index.php
4.htaccess