Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set location with extension in NGINX server

I'm new with NGINX server and I was wondering how to set something like this.

location phpmyadmin \.(gif|jpg|png)$ {
    root /usr/share/phpmyadmin;
}

example above fails at server restart.

Thanks for all answers.

UPDATE:

location ~* .(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|html|htm|wml)$ {
    root /home/safeftp/www/public_html;
}

location ~ "phpmyadmin \.(gif|jpg|png)$" {
    root /usr/share/phpmyadmin;
}
like image 773
Peter Bielak Avatar asked Mar 22 '15 13:03

Peter Bielak


1 Answers

If you want to use regex, use ~ (for case-sensitive matching) or ~* (for case-insensitive matching). Your location block should look like this:

location ~ "phpmyadmin \.(gif|jpg|png)$" {
    root /usr/share/phpmyadmin;
}

You can read more here: http://nginx.org/en/docs/http/ngx_http_core_module.html#location

like image 161
Donovan Hernandez Avatar answered Nov 24 '22 01:11

Donovan Hernandez