rewrites...

steve steve at greengecko.co.nz
Tue Sep 20 05:03:59 UTC 2016


Hi folks,

I am running php as fastcgi, replacing a working apache/mod_php setup. 
I'm pretty close, but am not quite there.

The last bit I've got to get working is...

     RewriteRule ^(.*)$ index.php [E=query:$1,L]

Which I understand to mean pass the request in a variable called query.

My (not working ) attempt is:

         location / {
                try_files $uri $uri/ @rewriteapp;
         }

         location @rewriteapp {
                 fastcgi_param query $request_uri;
                 rewrite ^(.*)$ /index.php last;
         }

         # Pass the php scripts to fastcgi server specified in upstream 
declaration.
         location ~ \.php(/|$) {
             # Unmodified fastcgi_params from nginx distribution.
             include fastcgi_params;
             # Necessary for php.
             fastcgi_split_path_info ^(.+\.php)(/.*)$;
             fastcgi_param PATH_INFO $fastcgi_path_info;
             fastcgi_param SCRIPT_FILENAME 
$realpath_root$fastcgi_script_name;
             fastcgi_param DOCUMENT_ROOT $realpath_root;
             try_files $uri $uri/ /index.php$is_args$args;
             fastcgi_pass backend;
         }

Can anyone point out where I'm going wrong please?

Cheers,

Steve

-- 
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa



More information about the nginx mailing list