4

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...

longi
  • 11,104
  • 10
  • 55
  • 89

2 Answers2

2

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
Some Java Guy
  • 4,992
  • 19
  • 71
  • 108
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?!

longi
  • 11,104
  • 10
  • 55
  • 89
  • Thanks, it was really helpful for me, mp4 wouldn't play on ipad in restricted directordy so I had to allow direct access to them and it's working fine now! – Mika Andrianarijaona Apr 07 '14 at 12:35
  • 1
    @Mika: you`re welcome, but keep in mind that users WITHOUT password are able to watch the videos, if they know the direct url! (so your videos aren`t really secured..) – longi Apr 07 '14 at 13:46
  • Yes that's true, but this is only for a staging website, not the production version which will no have the restriction. – Mika Andrianarijaona Apr 08 '14 at 16:00