Answer the question
In order to leave comments, you need to log in
Setting up rewrite on nginx/lighthttpd?
Hello, there is a task to download files from a server that is not really a web server and is pretty decently loaded with all sorts of things. Choose light as a web server (to be honest, I don’t know why, you can easily replace it with nginx, for example).
I need to download a file located in /home/user/some/folder/ 10 /subfolder/filename.ext at 123.45.67.89:8888/ 10 /filename.ext. Moreover, only from this folder and not higher than the level.
The number 10 in bold is some unknown number in advance, repeated in the file address in the specified location. You can’t generate a bunch of static rules, you can’t install php / python either. There is perhaps a pearl, but I don’t know it at all.
Is it possible to solve this problem using a web server, or will I have to write an indescribable script that does this?
Answer the question
In order to leave comments, you need to log in
exclude the subfolder from the path, it is not needed, or add a subfolder to the url, crutches in this case are not justified.
nginx:
location ~ ^/(\d+)/(.+)$ {
alias /home/user/some/folder/$1/subfolder/$2;
}
PS not sure about \d, if it doesn't work try [0-9] instead of \d.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question