Rewrite help when files do NOT have a ".php" extension

pk899 nginx-forum at
Wed Jun 1 18:32:00 MSD 2011

António P. P. Almeida Wrote:

> This won't work unless you have defined the name
> of the script that is
> to be executed by the upstream fastcgi process.
> What is the name of the script that receives the u
> argument? get.php? index.php?

Oh I see. I had totally misunderstood how this works. 

The name of the script is "/site/get". Without the .php extension. 

And the uri should be passed as "?u=" and in some case there will be a
second variable "&sb=". The rewrite rules will work this way: 

    location / {
      rewrite   ^/([-~a-zA-Z0-9_\.]+)(.+)$    /site/get?u=$1&sb=$2; 
      rewrite   ^/([-~a-zA-Z0-9_\.]+)$        /site/get?u=$1; 
So basically I can do the upstream bit this way? 

          include         fastcgi_params;
          fastcgi_param   SCRIPT_FILENAME   $document_root$/site/get;
          fastcgi_param   PATH_TRANSLATED   $document_root$/site/get;

Thanks for any ideas. (This is not working)

Posted at Nginx Forum:,202956,203003#msg-203003

More information about the nginx mailing list