I’m new to WordPress as I normally code my stuff by hand, I’ve been uploading some media to display links to within protected pages, which is great, however, anyone can access the direct url of the media. Does anybody have a suggestion how to stop this? I’m reluctant to just go hacking into .htaccess.
Leave a Reply
You must be logged in to post a comment.
The first thing you need to do is disable direct access to the directories the files are stored in by uploading blank index.html files to wp-content/uploads/ and all of its subdirectories. That way no one can go browsing around your upload directories finding that media manually.
In order to keep search engines from crawling your protected pages and users viewing it for free in searches, you may also want to add noindex meta tags to the section of your protected pages:
Or you can disallow the protected pages manually, or the protected directory as a whole by adding them to your robots.txt file.
To prevent hotlinking of images and other media, you’re going to need to upload the premium media to a specific directory, then simply add the following ReWrite rule to your .htaccess file:
Add as many file extensions as you’d like on the last line, separated by pipes. Obviously, you also want to replace your_domain.com in the code above.
If you’d like those who hotlink to see a “no hotlinking”, use the following code in your .htaccess file:
You can also change the final line of the above code to a specific URL you’d like to re-direct visitors to, like your homepage or a landing page asking users to become a premium member to view the content.