简体   繁体   English

使用 nginx 将 URL 重写为 MP4 视频

[英]Rewrite URL to MP4 video with nginx

I want to rewrite example.com/videos/name/ to the MP4 file videos/name.mp4 and serve it with content type video/mp4 as if the user would have requested the video directly with example.com/videos/name.mp4 .我想将example.com/videos/name/重写为 MP4 文件videos/name.mp4并使用内容类型video/mp4提供它,就好像用户会直接使用example.com/videos/name.mp4请求视频一样.

How can I do that with nginx ?我怎么能用nginx做到这一点?

I got it:我知道了:

location = /videos/ {
    types { } default_type "video/mp4";

    rewrite ^/name/$ /videos/name.mp4 last;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM