rewrite - Nginx - Redirect url for certain file type -


i have nginx 1.2.1. want rewrite:

http://mywebsite.com/[token].mp4 http://mywebsite.com/get.php?token=[token]

return error 404, block:

location ~* \.(mp4)$ {     rewrite "^/([a-za-z0-9]{23})\$" /get.php?token=$1 break; } 

i tried this question nothing, returns error 404

according nginx.conf provided here, try below:

location ^~ /videos/ {     rewrite "^/videos/([a-za-z0-9]{23})\.mp4$" /get.php?token=$1 break; } 

this should match url: example.com/videos/abc01234567890123456789.mp4 , redirect example.com/get.php?token=abc01234567890123456789

disclaimer: config not tested, may have typos


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -