Welcome! Log In Create A New Profile

Advanced

Rewrite before regex location

Joyce Babu
May 04, 2016 05:28PM
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
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?q=$1 last; }

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

set $fastcgi_script_name_custom $fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
set $fastcgi_script_name_custom "/cms/index.php";
}

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;}


Thank,
Joyce Babu

NB: This is a sample configuration. There are several such rewrite rules,
hence I cannot use a exact match or regular expression location block to
override the php proxy location block.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite before regex location

Joyce Babu May 04, 2016 05:28PM

Re: Rewrite before regex location

Francis Daly May 04, 2016 06:02PM

Re: Rewrite before regex location

Joyce Babu May 04, 2016 06:54PM

Re: Rewrite before regex location

Francis Daly May 04, 2016 07:16PM

Re: Rewrite before regex location

Joyce Babu May 04, 2016 07:46PM

Re: Rewrite before regex location

Anoop Alias May 04, 2016 10:24PM

Re: Rewrite before regex location

Joyce Babu May 06, 2016 04:18PM

Re: Rewrite before regex location

Francis Daly May 05, 2016 12:46PM

Re: Rewrite before regex location

B.R. May 06, 2016 07:54AM

Re: Rewrite before regex location

Joyce Babu May 06, 2016 04:38PM

Re: Rewrite before regex location

Joyce Babu May 06, 2016 06:26PM

Re: Rewrite before regex location

Joyce Babu May 06, 2016 06:30PM

Re: Rewrite before regex location

Robert Paprocki May 06, 2016 06:30PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready