Welcome! Log In Create A New Profile

Advanced

Rewriting

May 23, 2013 04:14PM
Hi,
I use opencart with nginx+php-fpm. Sometimes it is necessary to redirect all clients, except admin (190.212.201.0/24), to "Service unavailable" page which is simple index.html file with logo, background image and some text, located in /unav directory.
Below some of nginx.conf


location / {

if ($remote_addr !~ '190\.212\.201\.[0-9]{0,3}') {
rewrite ^/(.*)$ /unav/$1 break;
return 403;
}
try_files $uri $uri/ @opencart;
}

location ^~ /unav {
}

location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}

[...skipped...]

location ~ \.php$ {

try_files $uri =404;
fastcgi_read_timeout 60s;
fastcgi_send_timeout 60s;
include myphp-fpm.conf;

}

Problem is in rewriting.
This rule

rewrite ^/(.*)$ /unav/$1 break;

rewrite ONLY http://mysite.com/ request but in case http://mysite.com/index.php rewrite is none and request processed by location ~ \.php$ rule. Why??

Thanks!


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

Rewriting

artem May 23, 2013 04:14PM

Re: Rewriting

Bozhidara Marinchovska May 23, 2013 05:48PM

Re: Re[2]: Rewriting

B.R. May 24, 2013 01:00PM

Re: Rewriting

Francis Daly May 25, 2013 06:08AM

Re: Rewriting

Francis Daly May 26, 2013 05:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready