safari

Serving media files to Safari behind Basic HTTP Authentication

One issue I've run into with Safari is that certain media files like mp4, m4v, and mp3 will not load when being served from a directory that is behind Basic HTTP Authentication.

Alternatively, on some versions of Safari, it seems to result in a login prompt for each chunk of the media file that is being loaded.

One way of getting around this is to exclude those specific file types from requiring authentication by adding the following snippet to your http.conf or .htaccess file

# Exempt certain media files from password protection to prevent extra login prompts
<Files ~ "\.(mp4|m4v|mp3)">
    AddType video/mp4 mp4
    AddType audio/x-mp3 mp3
    order allow,deny
    allow from all
    satisfy any
</Files>