There are so many ways to do it...
The most simple is
rewrite ^/product/ /product.php;
at the server context. Your original request URI (i.e. /product/1.html) will be available for product.php script as $_SERVER['REQUEST_URI'] array item value.
You can also use rewrite directive at the location context, this can be slightly (very slightly) more performant:
location /product/ {
rewrite ^ /product.php last;
}
If you want, you can get product code and pass it to your product.php script as a query argument:
rewrite ^/product/(.*)\.html$ /product.php?product=$1;
or
location /product/ {
rewrite ^/product/(.*)\.html$ /product.php?product=$1 last;
}
This way your product code (1 for the /product/1.html URI, 2 for the /product/2.html URI, etc.) will be available for product.php script as $_GET['product'] array item value.
You can even define an individual FastCGI handler for this:
location /product/ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/product.php;
fastcgi_pass <fastcgi_upstream_or_socket>;
}
(original request URI will be available via $_SERVER['REQUEST_URI']), or if you want for product code to be available via $_GET['product']:
location ~ /product/(.*)\.html$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/product.php;
fastcgi_param QUERY_STRING product=$1;
fastcgi_pass <fastcgi_upstream_or_socket>;
}