404 error nginx rewrite
<p>I'm trying to redirect like this</p>

<p><code>/(int)/(lowercase string)/(int)/(lowercase string)/(string containt everything)?querystring</code></p>

<p>to</p>

<p><code>/$1/$2/$3.$4</code></p>

<p>example: <code>/81/file/221/zip/Filename.Zip</code> to <code>/81/file/221.zip</code></p>

<p>because some download managers won't look at my content-disposition header now this is my config file</p>

<pre><code>server {
    listen xxx.xxx.xxx.xxx:80;
    access_log /var/log/nginx/access.example.com.log;
    error_log /var/log/nginx/error.example.com.log;
    server_name example.com www.example.com;
    root /path/to/root/dir;

    valid_referers none blocked example.com *.example.com;
    if ($invalid_referer) {
        return 403;
    }

    location / {
        autoindex off;
        deny all;
        location ~ "\.(zip|mkv|mp4)$" {
            allow all;
            rewrite ^/(\d+)/([a-z]+)/(\d+)/([a-z]+)/(.*)$ $1/$2/$3.$4 break;
            add_header Content-Disposition 'attachment; filename="$arg_adlfname"';
        }
    }

    error_page 500 502 503 504 /50x.htm;
    error_page 403 /403.htm
    error_page 404 /404.htm
}
</code></pre>

<p>but it gives me 404 ... so what should I do ?</p>

<p><strong>AND MAYBE</strong> !
isn't it better do set the rule with the location ? maybe rewrite isn't needed</p>