I have mp3 players set up to play mp3s on my site. The mp3s are all being uploaded to the uploads folder. I don’t want people accessing these directly, meaning I don’t want people to be able to download the mp3s. Is there a way to somehow restrict access to all files ending in .mp3 in the uploads folder while still having them playable in the mp3 players on the site?
Leave a Reply
You must be logged in to post a comment.
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:
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:
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:
It support multiple files extensions including:
I hope this help you better. Let me know if there is any query regarding this.
You could do this one of two ways.
1) Simple way. Create a new file in your mp3 directory called index.php, and add this code to it
What this is doing is when a user goes to browse your directory, the web server will serve them the index.php file. Since there is no code in it, the user will be served a blank webpage as a result.
2) Do this through
.htaccess
In your website’s root directory should be a
.htaccess
file. Open this up and add something likeThe Redirect will automatically redirect anyone who tries to access the /mp3/ folder and send them to your main website of mysite.com. The 403 tells the browser that the request is Forbidden.