【发布时间】:2019-07-03 13:04:38
【问题描述】:
我试图在我的 htaccess 文件中使用 mod_rewrite 来保护我的 mp3。
我读过这个帖子:
how to write a .htaccess redirect like stackoverflow does for its questions
htaccess rewrite dynamic mp3 to dynamic php?
How to hide filename from url by using .htaccess
这个网站:
https://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049
还有这个视频:
https://www.youtube.com/watch?v=uPlZekNEU60
我能够使用这条规则将文件名重写为 filename.pdf:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.pdf -f
RewriteRule ^([^\.]+)$ $1.pdf [NC,L]
现在,为了保护我的 mp3,我想重写我的网址
filename.mp3/?uuid=something to https://cdn.com/123456/t/filename.mp3
我试过这条规则:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.mp3 -f
RewriteRule ^([a-zA-Z0-9]{30})$ https://cdn.com/123456/t/$1.mp3 [NC,L]
但它不起作用
我试过这个:
RewriteRule ^(\w*.mp3)+)$ https://cdn.com/123456/t/$1 [NC,L]
但它会使网站关闭:(
有什么建议吗?
【问题讨论】:
-
我的回答对你有用吗?
-
感谢您的回答,这个周末我会尝试您的解决方案,我会及时通知您! :)