Match any location except particular one
mennanov
nginx-forum at nginx.us
Wed Nov 23 13:27:55 UTC 2011
Hello, i have a website with the following files structure:
engine/
__index.php
webroot/
__images/
__css/
__cms/
______engine/
_________index.php
______webroot/
_________images/
_________css/
others/
So the folder "cms" is placed in a webroot of the main site. The point
is that all queries like "/js/jquery.js" must be treated as
"/webroot/js/jquery.js" and all cms queries like "/cms/js/jquery.js"
must be treated as "/webroot/cms/webroot/js/jquery.js". 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:
server {
listen 8080;
server_name glinka.fm;
root /home/renat/www/glinka;
index index.php index.html;
# rules for all queries except /cms/ (how to do that??) "location ~
/(?!cms)" makes a cycle and 500 error
location / {
try_files /webroot/$uri /engine/index.php;
}
# rules for /cms/ queries only
location /cms/ {
rewrite /cms/(.*) /webroot/cms/webroot/$1;
if (!-f $request_filename) {
rewrite (.*) /webroot/cms/engine/index.php;
}
}
location ~ \.php$ {
include fastcgi.conf;
}
}
Please help me
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,218819,218819#msg-218819
More information about the nginx
mailing list