My site contains a lot of custom images. I've searched the web and found a lot of websites that link directly to the images on my site. Meaning, they link to the jpeg itself, not to the actual page on my site that contains the jpeg. When someone clicks the link, it only shows the image against a blank page background. There is no site content.
I'd like when someone clicks the link on the other site that it opens the image on a page with my main menu, etc. so they can navigate my site.
Is there any way to do this?
Disclaimer: I realize this may sound like a naïve question, and that when someone links to an image, there would be no way to know if they were linking to the image from within a page, or to the image directly. But I'm wondering if someone has found a work-around, such as, if the image link is coming from an external site... etc.
My site contains a lot of custom images. I've searched the web and found a lot of websites that link directly to the images on my site. Meaning, they link to the jpeg itself, not to the actual page on my site that contains the jpeg. When someone clicks the link, it only shows the image against a blank page background. There is no site content.
I'd like when someone clicks the link on the other site that it opens the image on a page with my main menu, etc. so they can navigate my site.
Is there any way to do this?
Disclaimer: I realize this may sound like a naïve question, and that when someone links to an image, there would be no way to know if they were linking to the image from within a page, or to the image directly. But I'm wondering if someone has found a work-around, such as, if the image link is coming from an external site... etc.
Share Improve this question asked Oct 3, 2019 at 2:02 Francisco d'AnconiaFrancisco d'Anconia 1012 bronze badges 3- 1 You can always stop image leaching. That way nobody will be able to direct link your images in their website. – Sabbir Hasan Commented Oct 3, 2019 at 6:40
- That's an option, but seems like a last resort. How can I configure this in WordPress? – Francisco d'Anconia Commented Oct 3, 2019 at 16:55
- Check my answer below. You will need some skill to achieve this. – Sabbir Hasan Commented Oct 3, 2019 at 18:59
1 Answer
Reset to default 0You need to edit .htaccess file and add following line right after current lines. You can edit the file from cpanel or FTP. Also there is a WordPress Plugin that allows to edit .htaccess file.
Remember it's a very advanced thing to do. So make sure to backup current file before editing. Any error will cause site not loading.
/* Prevent image hotlinking in WordPress */
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourwebsite [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [F]
This will let only youtube, google, facebook and twitter to directly Link you images. All other websites will be blocked.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745108791a4611719.html
评论列表(0条)