Hi, I'm struggling with getting rewrites to work so that I can hide the ".php" on file extension. I'm running a photo site (called Piwigo) on nginx, and it creates URLs of the form:
http://example.com/SOMESCRIPT/param1/param2/param3#whatever
In this case, SOMESCRIPT is actually a file on disk called "SOMESCRIPT.php". I'm trying to configure rewrites so that (1) first try to see if the URL is a path on disk; (2) if not, try to send it on to the PHP script by adding a ".php" after the first word in the URI.
Here's the relevant section that I've tried. Any help is most welcome.
location / {
index index.php;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/picture((/|$).*)$ /picture.php$1 last;
rewrite ^/index((/|$).*)$ /index.php$1 last;
rewrite ^/i/(.*)$ /i.php/$1 last;
rewrite ^/../../../i/(.*)$ ../../../i.php/$1 last;
}
http://example.com/SOMESCRIPT/param1/param2/param3#whatever
In this case, SOMESCRIPT is actually a file on disk called "SOMESCRIPT.php". I'm trying to configure rewrites so that (1) first try to see if the URL is a path on disk; (2) if not, try to send it on to the PHP script by adding a ".php" after the first word in the URI.
Here's the relevant section that I've tried. Any help is most welcome.
location / {
index index.php;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/picture((/|$).*)$ /picture.php$1 last;
rewrite ^/index((/|$).*)$ /index.php$1 last;
rewrite ^/i/(.*)$ /i.php/$1 last;
rewrite ^/../../../i/(.*)$ ../../../i.php/$1 last;
}