Safari html5 video mp4 not playing in htaccess folder, [duplicate]

我们两清 提交于 2019-12-22 08:46:12

问题


i m just working on a private page with some videos, which should only be accessible through htaccess. all videos are html5 encoded, and the site works fine for every browser without the htaccess file.

after putting the htaccess file to my server, safari fails to load the mp4-videos. in charles i get an "401 Authorization Required".

i checked several posts here to the same topic, but didn't found a solution yet. if someone can push m in the right direction, go ahead!

some people solved this issue, while adding the mime types to the htaccess-file (see below). didn t work for me...anyone any ideas?

htaccess at root folder

AuthUserFile /rootpath/.htpasswd
AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/mp4 .mov
AddType video/webm .webm

<limit GET POST>
require valid-user
</limit>

htacess in video folder

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/mp4 .mov
AddType video/webm .webm

even checked it with some html5-example videos, so couldn t be wrong codec. keep in mind, it works perfect without the htaccess file, so i guess my configuration is still wrong. but i have no idea where the bug is...


回答1:


Try using below code

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
AddType video/ogg .ogv
AddType video/ogg .ogg
AddType video/mp4 .mp4
AddType video/webm .webm
AddType application/x-shockwave-flash swf



回答2:


after a few more hours still haven t found a real solution... but for my case im using following tag in my .htaccess file:

<FilesMatch mp4>
Satisfy any
order allow,deny
allow from all
</FilesMatch>

the files are now directly accessible even for user without the htaccess password. this is not really a solution, but for my case ok, since it is a private page.

still anyone better ideas?!



来源:https://stackoverflow.com/questions/9070724/safari-html5-video-mp4-not-playing-in-htaccess-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!