Prevent users from accessing mp3s in my uploads folder?

There is a simple approach to hold download access on your file.

1. Using .htaccess:

Upload a .htaccess file into your wp-content folder. Have a look if one exists already, then append this code to the end of the file. If you don’t have one, just create a new blank file and add this code to it:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourwebsite\.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(mp3|mp4|mov) [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule .*\.(mp3|mp4|mov)$ http://yourwebsite.com/ [NC]

This rather strange sounding code is neither Linux nor PHP nor MySQL – it’s Apache (that’s the service which usually takes care of serving up those websites from a server). These are instructions that will tell Apache to do the following – I’ll explain this line by line.

Here are some instructions I’d like you to use in this directory:

  1. IF someone comes from anywhere other than yourwebsite.com
  2. AND they ask for a direct file that ends with any of the following (mp3, mp4, mov, etc)
  3. AND they are not logged into WordPress on this domain
  4. THEN direct every link to such files to http://yourwebsite.com

If these conditions are not met, then give out the file – everyone’s happy.

2. Using Hide Real Download Path plugin:

This plugin helps you to hide real/direct path of files hosted on your server for download and make your files secure from unauthorized download. It also maintains a log of all downloads done using it and provide capability to disallow direct linking (hot linking) to your files from
other website.

With this you can:

  1. Allow or restrict hotlink (direct download) of your files from other website/external links.
  2. Restrict ‘download only’ from link on your website
  3. View log of individual download

It support multiple files extensions including:

zip / pdf / doc / xls / ppt / exe / gif / png / jpg / jpeg / mp3 / wav
/ mpeg / mpg / mpe / mov / avi / xlsx

I hope this help you better. Let me know if there is any query regarding this.

Leave a Comment

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino