javascript - .htaccess rules make sm2 fail to load mp3s of my website on Android and iPad -


i use .htaccess in application's assets/audio directory prevent direct download of mp3's files played . following code of .htaccess placed in assets/audio directory:

rewriteengine on  rewritecond %{http_referer} !^http://(www\.)?localhost [nc]  rewritecond %{http_referer} !^http://(www\.)?localhost.*$ [nc]  rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net [nc]  rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net.*$ [nc]  rewriterule \.(gif|jpg|mp3)$ - [r=401] errordocument 401 /e401.html addtype audio/mpeg mp3 

with desktop (windows 7), web browser able play sounds soundmanager2. live demo found on following url: http://quran.2index.net/viewayah/1

the problem android web browser, opera on android , safari of ipad (those have tested with). browsers not able load mp3 audio file , download file popped up!

the weird thing me, when comment out lines of .htaccess regarded above (except first , last lines), sm2 becomes work fine on android , ipad!

i wonder, what's relation between server-side .htaccess , client-side web client? or what's issue in .htaccess make sm2 works fine browser on windows7 desktop while not works on android web browser , ipad?! there suggestions?

soundmanager2 falls flash html5 iphone, ipad (and android assume) , html5 element not provide http_referer tag when attempts retrieve media file needs play. .htaccess file therefore rejects request throwing forbidden response.

i've been able find else on stackoverflow issue (albeit video within html5). solution add user_agent test .htaccess file. i've tested thread's solution , solves soundmanager2 issue too.

.htaccess http_user_agent not working

although it's not fail safe solution (as i'm told header info can over-written wishing bypass user_agent check) it's work-around gets player working...

[solution copied link above produce following particular question]

rewriteengine on rewritecond %{http_user_agent} !(android|ipod|iphone|ipad) [nc] rewritecond %{http_referer} !^http://(www\.)?localhost [nc]  rewritecond %{http_referer} !^http://(www\.)?localhost.*$ [nc]  rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net [nc]  rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net.*$ [nc]  rewriterule \.(gif|jpg|mp3)$ - [r=401] errordocument 401 /e401.html addtype audio/mpeg mp3` 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -