Welcome! Log In Create A New Profile

Advanced

Issue with multiple location blocks to handle two webapps

August 28, 2012 12:42AM
Hi All,

My webapp is a combination of two apps running on one server.

the community app (smaller one) is located under community directory and
the all urls starting with community should be handled by it
e.g. example.com/community/questionsexample,com/community/2/an-actual-qestion
etc etc

The main app takes care of rest of URLs such as example.com (which should
redirect to example.com/city) example.com/city/sampledir etc etc

the location blocks I have used are
----------------------
#handle community section separately
location ^~ /*community*/ {
try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
access_log off;
}
}

location =/ {
#convert domain to domain/city
rewrite ^(.*)$ $scheme://example.com/city permanent;
}

#these locations always use /city as prefix
location ~^/(biz|biz/|profiles|profiles/) {
rewrite ^(.*)$ $scheme://example.com/city$1 permanent;
}

#main app should handle everything except community
location* /* {
#remove trailing slash
rewrite ^/(.*)/$ /$1 permanent;
#NB this will remove the index.php from the url
try_files $uri $uri /index.php?$args;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
access_log off;
}
-------------------------------
With this code the main app works fine but the community app ONLY works for
example.com/community/ and example.com/community/?a=foo/bar etc etc but *NOT
* for example.com/community/foo/bar

I think example.com/community/foo/bar doesn't get handled by the community
location block and goes to the main location which gives 404 error.

I tried various combination for location but nothing is fixing it
perfectly. I will appreciate any pointers / help.

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

Issue with multiple location blocks to handle two webapps

goltus August 28, 2012 12:42AM

Re: Issue with multiple location blocks to handle two webapps

Francis Daly August 28, 2012 04:26AM

Re: Issue with multiple location blocks to handle two webapps

goltus August 28, 2012 05:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
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