Welcome! Log In Create A New Profile

Advanced

Re: Match any location except particular one

Francis Daly
November 23, 2011 09:48AM
On Wed, Nov 23, 2011 at 08:27:55AM -0500, mennanov wrote:

Hi there,

> I spent 2 days
> writing a proper config, the main problem is that all queries to /cms/
> location MUST NOT be parsed in "location / {...}" and all queries in
> "location /cms/ {...}" must not be parsed in "location / {...}"
>
> Here is my config:

You have three top-level location{} blocks here.

You probably only want two.

> location / {

This will match all requests that don't match another location.

> # rules for /cms/ queries only
> location /cms/ {

This will match all requests that begin "/cms/", unless they match
another location.

> location ~ \.php$ {

This will match all requests that end in ".php". Specifically including
both "/index.php" and "/cms/index.php". Which is likely not what you want.

In nginx, every request is handled by one location{} block.

See, for example, http://wiki.nginx.org/HttpCoreModule#location for
details of how the one is chosen.

So you probably want something like

location / {
# all "location /" config
location ~ \.php$ {
# all "php inside location /" config
}
}

location /cms/ {
# all "location /cms/" config
location ~ \.php$ {
# all "php inside location /cms/" config
}
}

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Match any location except particular one

mennanov November 23, 2011 08:27AM

Re: Match any location except particular one

Francis Daly November 23, 2011 09:48AM

Re: Match any location except particular one

mennanov November 23, 2011 10:11AM

Re: Match any location except particular one

Igor Sysoev November 23, 2011 11:18AM

Re: Match any location except particular one

mennanov November 23, 2011 11:26AM

Re: Match any location except particular one

Igor Sysoev November 23, 2011 11:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 98
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready