[solved] Analog url.rewrite-once on nginx

Recently decided to try to replace lighttpd to nginx. However, I can not overcome the design of the form (lighttpd.conf):
url.rewrite-once = ( "^/api/(.*)$" => "/m/microcosm.php/$1" )<br>
The script is not mine — wiki.openstreetmap.org/wiki/Microcosm. Used to store "secret" data from JOSM.
All that I managed — when you enter an address server/api/ me throws on server/m/microcosm.php
October 8th 19 at 03:05
2 answers
October 8th 19 at 03:07
In General terms it would be something like. Microcosm is not used, will probably have finished the configuration.

 ## Microcosm
 location /api/
 #location ~ ^/api/(.*)
{
 ## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 location php_backend; # specify upstream

 root /path/to/microcosm/m/; # a directory microcosm.php or prescribe $document_root
 fastcgi_index microcosm.php;

 include fastcgi_params;
 #fastcgi_param QUERY_STRING $query_string;
 #fastcgi_param REQUEST_URI $1;
 fastcgi_param SCRIPT_FILENAME $document_root/microcosm.php;
}
Alas. The script can't know what was in the URL host/api/URL
Details in addition to issue. - Alvera commented on October 8th 19 at 03:10
October 8th 19 at 03:09
rewrite ^/api/(.*)$ /m/microcosm.php/$1 break;
either
rewrite ^/api/(.*)$ /m/microcosm.php/$1 last;
if you then need to handle other lokalny (e.g. a single location, catching *.php).
If I understand correctly, you should get this design?
location /api/ {<br> rewrite ^/api/(.*)$ /m/microcosm.php/$1 last;<br> }<br>
This code is not working. nginx tries to open the file inside the folder microcosm.php and, of course, it is not possible:
2012/02/22 14:04:03 [error] 67145#0: *4 "/home/web/htdocs/m/microcosm.php/0.6/index.php" is not found (20: Not a directory), client: 10.xx.xx.xx, server: localhost, request: "GET /api/0.6/ HTTP/1.1", host: "10.yy.yy.yy"<br> 2012/02/22 14:04:34 [error] 67145#0: *4 "/home/web/htdocs/m/microcosm.php/index.php" is not found (20: Not a directory), client: 10.xx.xx.xx, server: localhost, request: "GET /m/microcosm.php/ HTTP/1.1", host: "10.yy.yy.yy"<br> - Alvera commented on October 8th 19 at 03:12
Well, that makes sense. I suspect that there is not enough of another rewrite that turns that after microcosm.php in query params.
The second option is to remove the /$1 (if the microcosm itself parses the url. I, unfortunately, don't know how it's arranged) - Alvera commented on October 8th 19 at 03:15

Find more questions by tags LighttpdNginxProcessing URL