Rewriting all requests to index.php

I’m new to Nginx. How do I rewrite all requests to index.php? So for
example, if http://www.example.com/some/path/ is requested, I’d like
http://www.example.com/index.php to transparently handle it.

How can I do this?

Posted at Nginx Forum:

12.07.10, 23:46, “astrochase” [email protected]:

I’m new to Nginx. How do I rewrite all requests to index.php? So for
example, if http://www.example.com/some/path/ is requested, I’d like
http://www.example.com/index.php to transparently handle it.

How can I do this?

location / {
root /path/to/www;
include fastcgi_params;
fastcgi_pass …;
fastcgi_param SCRIPT_FILENAME /path/to/www/index.php;
}


br, Denis F. Latypoff.

Got it! Thank you!

Posted at Nginx Forum:

You can use also the try_files (
http://wiki.nginx.org/NginxCoreModule#try_files ) approach:

location / {
try_files $uri $uri/ /index.php?$args;
}

This way you can also have normal directories and static files and nginx
will check first if they exist and if not then use the /index.php in the
root folder.

rr