I am trying to get Nginx to rewrite URL space ./data/(.+).png to serveImage.php?guid=$1
server {
server_name my.server;
listen 80;
listen 127.0.0.1:80;
root /var/www/my.server;
index index.html;
location / {
try_files $uri $uri/ index.html;
rewrite ^/data/(.+).png serveImage.php?guid=$1 last;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
What am I doing wrong? serveImage.php
does exist in the document root.
Rewriting did not seem to work as planned (nothing that appeared to access.log or error.log gave even a hint that the rule was even caught). I made a more generic router that might fit better the other yet unknown needs as well.
Well if it's always
/data
I would create a specific location for it, like thisTry this and tell me if it works.