Rewrite and FastCGI.

Francis Daly francis at daoine.org
Tue Oct 9 12:53:11 UTC 2012


On Tue, Oct 09, 2012 at 02:03:40PM +0200, Thomas Martin wrote:

Hi there,

>         # dir1
>         location /dir1 {
>                 rewrite ^(.*) https://$host$1 permanent;
>         }
> 
>         # php5-fpm
>         location ~ \.(php|phtml)$ {
>                         include         /etc/nginx/fastcgi_params;
>                         fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
>                         fastcgi_param   SCRIPT_FILENAME
> /www/$fastcgi_script_name;
>                 }
>         }

> The rewrite is working great for a html page (for example) but not for
> a php page.

One request is handled in one location.

You have

    location /dir1 {}
    location ~ \.(php|phtml)$ {}

Possibly what you want is

    location ^~ /dir1 {}
    location ~ \.(php|phtml)$ {}

or maybe

    location /dir1 {}
    location / {
      location ~ \.(php|phtml)$ {}
    }

See http://nginx.org/r/location for details.

(Possibly what you want is some other configuration: the important thing
to keep in mind is: for this request, which one location do you wish to
handle it? Then configure the locations accordingly.)

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list