重写一个URL到一个新的URL,然后发送新的URL到一个PHP脚本

我有包含caching清除string的URL。 我想重写这些URL而不使用caching清除string,然后将符合特定条件(如audio/video文件)的重写URL发送到PHP脚本。

例如

/style.1233333555.css => /style.css /video.3232474527.mp4 => /video.mp4 => /index.php 

以下是我到目前为止:

 server { listen 80 default_server; server_name _; #force all traffic to be encrypted return 301 https://xyz.com$request_uri; } server { listen 443 ssl; server_name xyz.com; ssl on; ssl_session_timeout 5m; ssl_protocols TLSv1.1 TLSv1.2; ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; ssl_prefer_server_ciphers on; ssl_certificate /etc/nginx/ssl/xyz.com.crt; ssl_certificate_key /etc/nginx/ssl/xyz.com.key; root /srv/xyz.com; index index.php; #for all files in the format "name.0000000.ext" eg "child.3126043152.jpg" location ~ (.*\/)?([^/]+)\.[a-zA-Z0-9]+(@2x)?\.([^\.]+)$ { #cache the files for as long as possible expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; #remove the cache busting string and rewrite to the file's actual url rewrite (.*\/)?([^/]+)\.[a-zA-Z0-9]+(@2x)?\.([^\.]+)$ $1$2$3.$4 last; } #pass media files through index.php so we can duplicate the actual file rewrite \.(mp3|mp4|m4v|avi)$ /index.php; #specify which files we can X-Accel-Redirect to location /media { internal; alias /srv/xyz.com; } #pass anything that doesn't exist through index.php location / { try_files $uri $uri/ /index.php; } #tell nginx how to handle PHP files location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

此configuration不会产生任何错误,但不会将audio/video转发到PHP脚本。

我究竟做错了什么?

谢谢。