Rewrite help when files do NOT have a ".php" extension
António P. P. Almeida
appa at perusio.net
Wed Jun 1 18:53:53 MSD 2011
On 1 Jun 2011 15h32 WEST, nginx-forum at nginx.us wrote:
> 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;
> #--------------
Then use an exact location:
location = /site/get {
include fastcgi_params;
# Where's the fastcgi_pass directive?
fastcgi_pass unix:/path/to/socket.sock;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_filename;
}
I suggest you either use the echo module by agentzh or enable the
error log with the debug flag to see what's going on.
http://wiki.nginx.org/CoreModule#error_log
--- appa
More information about the nginx
mailing list