bravo14 Posted March 26, 2014 Share Posted March 26, 2014 Hi Guys I am in the world of trying to prevent copyrighted images being downloaded and have entered the following line into my .htaccess file RewriteRule \.(gif|jpg|js|txt|png)$ /messageforcurious [L] It works in the fact that I cannot enter the image name into the address bar, but it also prevents pages from downloading the images, is it possible to prevent the user downloading the images using .htaccess? Quote Link to comment https://forums.phpfreaks.com/topic/287286-htaccess-prevent-image-download/ Share on other sites More sharing options...
mac_gyver Posted March 26, 2014 Share Posted March 26, 2014 when you put an image onto a web page, the browser takes the url of that image from the html markup and 'downloads' the image in order to display it. therefor, you cannot prevent http access to the image and have it displayed on a web page. Quote Link to comment https://forums.phpfreaks.com/topic/287286-htaccess-prevent-image-download/#findComment-1473970 Share on other sites More sharing options...
Psycho Posted March 26, 2014 Share Posted March 26, 2014 To expand on mac_gyver's response: It is impossible to display an image on a web page and to protect it from someone who want to have a copy of it. First off, if an image is displayed to a user in a web page, it has already been downloaded to their computer. That is how it works. The image is sitting their in the user's cache. Many users may not know where the cache is or how to access it, but the reality is that it is already there. I see some sites go to great lengths in trying to prevent users from copying images. In some cases those measures actually cause more problems than the one they are trying to solve. A couple examples: JavaScript to prevent right-clicking so the user can't do a "Save as" on the image. OK, but that also prevents the user from using the other features in the context menu that they should be able to use. This behavior only pisses me off. Plus, users could simply disable JavaScript Putting a transparent image on top of the 'protected' image. This is done so when the user tries to copy the image they are really only copying the transparent image on top. This can cause problems with page layouts because of the idiosyncrasies between web browsers with the more complicated positioning and layering used to accomplish this - especially with smart phones and tablets. Plus, a user can simply do a screen capture to get the image. What should you do (in my opinion). 1. Watermark the images. That way someone can't reuse your images without people knowing they copied it from someone. 2. Prevent hot-linking to your images. The watermark really makes this less about protecting the image than about not letting someone to use your bandwidth. In other words, if someone has already decided to use your image on their site, preventing the hot-linking will require them to copy it and host it themselves instead of just including an image tag on their site pointing to your server. So, to reiterate, you cannot prevent someone from copying the images if you are going to make it available on the internet - period. All you can do is make it marginally harder. But, even doing those things adds a lot more work and complexity that really doesn't accomplish anything because it would take someone with just a little knowledge no more than a couple seconds to still get the image. Quote Link to comment https://forums.phpfreaks.com/topic/287286-htaccess-prevent-image-download/#findComment-1473984 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.