I need to migrate a website from Apache to Nginx.
In this project, there is a .htaccess with theses rules :
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=logofile:/temp/logo/%2.%3.%4.%5]
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=logopath:%{DOCUMENT_ROOT}%{ENV:logofile}]
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=capturefile:/temp/capture/%2.%3.%4.%5]
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=capturepath:%{DOCUMENT_ROOT}%{ENV:capturefile}]
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=genericfile:/temp/generic/%2.%3.%4.%5]
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=genericpath:%{DOCUMENT_ROOT}%{ENV:genericfile}]
RewriteCond %{ENV:logofile} !^$
RewriteCond %{ENV:logopath} -f
RewriteRule .* %{ENV:logofile} [L]
RewriteCond %{ENV:capturefile} !^$
RewriteCond %{ENV:capturepath} -f
RewriteRule .* %{ENV:capturefile} [L]
RewriteCond %{ENV:genericfile} !^$
RewriteCond %{ENV:genericpath} -f
RewriteRule .* %{ENV:genericfile} [L]
I tried converting these in the Nginx block with the following code:
location ~* ^/(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+) {
try_files $uri $uri/ /temp/logo/$2.$3.$4.$5 /temp/capture/$2.$3.$4.$5 /temp/generic/$2.$3.$4.$5;
}
But it doesn't work ... However, this directive works, but it is not enough:
rewrite ^/(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+) /temp/capture/$2.$3.$4.$5;
If you can help me with this problem, that will be great :)
Christophe