Welcome! Log In Create A New Profile

Advanced

How to get the Request file name

Posted by suvaraj 
How to get the Request file name
December 23, 2014 08:45PM
Hi,
I am trying to configure in nginx where I have a request which is coming like "GET /images/abc.jpg HTTP/...."I wanted to write a IF condition which should make a variable true if the request is for abc.jpg or images folder and I wanted to use that variable value in below code to do other operation.
Please let me know how I can do it.

I have tried writting some thing as below,but it doesn't help me out.

location /images/abc.jpg {
# set $test I;
set $test "${test}I";
}

location ~* \.(gif|jpg|png)$ {
set $test "${test}I";

}

if ($request_uri ~ ".*/(images)/.*") {
set $test "I";
}

Also let me know how I can print the $test value in log to verify the value.



Edited 1 time(s). Last edit at 12/23/2014 08:47PM by suvaraj.
Re: How to get the Request file name
December 24, 2014 01:42PM
Use 'map' for this and then use the mapped variable in an 'if',
http://nginx.org/en/docs/http/ngx_http_map_module.html

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready