Reputation: 1144
I currently am blocking all access to one directory in on my server using .htacces
deny from all
I use php for all my coding, except at one point I use javascript to play mp3s from my secured directory. But this is blocked by the .htaccess
Is there anyway to allow the javascript access to the directory but still block people from typing in the url and gaining access to the files.
Sorry, I'm new to .htaccess and can't figure it out.
Thanks.
Upvotes: 2
Views: 2690
Reputation: 1144
I ended up using this code to allow access to mp3s and oggs and nothing else. It's not optimal but it works.
deny from all
<FilesMatch ".(ogg|mp3)$">
Order Allow,Deny
allow from all
</FilesMatch>
Thanks for the answers.
Upvotes: 0
Reputation: 6919
No, JavaScript
is client side; thus, if it can access the files, the client can too.
Considering moving the files into a non-public directory, perhaps even outside of webroot, and then reading them & sending them to the client using a script. This can be easily accomplished with PHP.
Upvotes: 4
Reputation: 2707
Nope, not that I'm aware of. Why don't you just move the music into another directory that has an index so all the music files aren't listed?
Upvotes: 1