Re: Rewrite before regex location

2016-05-06 Thread Robert Paprocki
See http://nginx.org/en/docs/http/ngx_http_core_module.html#location: 'The “@” prefix defines a named location. Such a location is not used for a regular request processing, but instead used for request redirection. They cannot be nested, and cannot contain nested locations.' On Fri, May 6, 2016

Re: Rewrite before regex location

2016-05-06 Thread Joyce Babu
Oops! The local configuration was *location ^~ @rewrite_news {...}* On Sat, May 7, 2016 at 3:54 AM, Joyce Babu wrote: > It is working fine on my mac. But when I try to use it on my Cent OS > server, it is failing with error > > nginx: [emerg] location "[^/]\.php$" cannot be inside the named loca

Re: Rewrite before regex location

2016-05-06 Thread Joyce Babu
It is working fine on my mac. But when I try to use it on my Cent OS server, it is failing with error nginx: [emerg] location "[^/]\.php$" cannot be inside the named location "@rewrite_news" Both are running version 1.10.0 :( ___ nginx mailing list ngin

Re: Rewrite before regex location

2016-05-06 Thread Joyce Babu
> > That's because your fastcgi_split_path_info pattern does not match - > .php is not followed by / in your rewritten url. > > Because of the location{} you are in, it is probably simplest to just > replace the second capture part of that pattern with (.*)$. > Thank you Francis. It worked after f

Re: Rewrite before regex location

2016-05-06 Thread Joyce Babu
Thank you for the suggestion, Anoop. I did not want to do that since it would be evaluated for every request. On Thu, May 5, 2016 at 7:52 AM, Anoop Alias wrote: > Hi , > > Can you try putting the rewrite in server{} block outside of all > location{} blocks like > > rewrite "^/test/([a-z]+).php$"

Re: Rewrite before regex location

2016-05-06 Thread B.R.
As a sidenote, why using location ~ ^/php-fpm/ and not location /php-fpm/ ? Although being distant to your case (I see others are helping you nicely :o) ), I can but particularly note & enjoy the use of a non-greedy modifier in the regex part of fastcgi_split_path_info intended to result in $fastc

Re: Rewrite before regex location

2016-05-05 Thread Francis Daly
On Thu, May 05, 2016 at 05:13:29AM +0530, Joyce Babu wrote: Hi there, > Is it possible to do something like this? > > location /test/ { > rewrite "^/test/([a-z]+).php$" /php-fpm/test/test.php?q=$1 last; > } > > location ~ ^/php-fpm/ { > location ~ [^/]\.php(/|$) { > fastcgi_spli

Re: Rewrite before regex location

2016-05-04 Thread Anoop Alias
Hi , Can you try putting the rewrite in server{} block outside of all location{} blocks like rewrite "^/test/([a-z]+).php$" /test/test.php?q=$1 last; On Thu, May 5, 2016 at 5:13 AM, Joyce Babu wrote: >> If you've got a messy config with no common patterns, you've got a messy >> config with no

Re: Rewrite before regex location

2016-05-04 Thread Joyce Babu
> > If you've got a messy config with no common patterns, you've got a messy > config with no common patterns, and there's not much you can do about it. > > If you can find common patterns, maybe you can make the config more > maintainable (read: no top-level regex locations); but you don't want >

Re: Rewrite before regex location

2016-05-04 Thread Francis Daly
On Thu, May 05, 2016 at 04:22:11AM +0530, Joyce Babu wrote: Hi there, > > Possibly using "location ^~ /test/" would work? > There are over 300 rewrites under 54 location blocks. If you've got a messy config with no common patterns, you've got a messy config with no common patterns, and there's

Re: Rewrite before regex location

2016-05-04 Thread Joyce Babu
Hi Francis, Thank you for the response. Possibly using "location ^~ /test/" would work? > > http://nginx.org/r/location > > You may want to rewrite to /test.php (with the leading slash), though. > > Although, better might be to just fastcgi_pass directly, rather than > rewriting. > > Something li

Re: Rewrite before regex location

2016-05-04 Thread Francis Daly
On Thu, May 05, 2016 at 02:56:27AM +0530, Joyce Babu wrote: Hi there, > When I add a > regex location block to match .php extension, it gets higher precedence, > and my rewrite rules are not applied. > > How can I resolve this? > > location /test/ { > rewrite "^/test/([a-z]+).php$" test.php

Rewrite before regex location

2016-05-04 Thread Joyce Babu
I am trying to migrate to Nginx + PHP-FPM from Apache + mod_php. I am currently using mod_rewrite to rewrite some virtual URIs ending in .php to actual PHP scripts. This works perfectly when using mod_php. But with with Nginx + FPM, since we have to use proxy_pass, this is not working. When I add a