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:
http://forum.nginx.org/read.php?2,108022,108022#msg-108022

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:
http://forum.nginx.org/read.php?2,108022,108026#msg-108026

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs