php and urls with /?xxx
António P. P. Almeida
appa at perusio.net
Sat Nov 19 01:38:13 UTC 2011
On 18 Nov 2011 23h31 WET, nginx-forum at nginx.us wrote:
> Ahoi,
>
> at the moment i use a "location \.php {}" block for opening
> php-files through fastcgi_pass. But what's the right way for calls
> like www.xxx.xxx/?xxx=xxx ?
>
> For Wordpress-Urls like /index.php/xxx/
> try_files $uri $uri/ /index.php?q=$request_uri;
> works fine, but for /?
Try this:
## Regular PHP processing.
location ~ ^(?<script>.+\.php)(?<path_info>.*)$ {
include fastcgi.conf;
## The fastcgi_params must be redefined from the ones
## given in fastcgi.conf. No longer standard names
## but arbitrary: named patterns in regex.
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
## Passing the request upstream to the FastCGI
## listener.
fastcgi_pass phpcgi;
}
Combined with:
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
Of course you have to fill in the details on static file handling,
blocking the readme.html file, etc.
--- appa
More information about the nginx
mailing list