How to protect against direct access to images?

前端 未结 9 1067
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 00:47

I would like to create a web site with many images. But I would like to protect against direct access to images, e.g. direct links to images without visiting the web site.

9条回答
  •  难免孤独
    2020-12-05 01:20

    Add Deny Rule in your .htaccess

    RewriteEngine on 
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.ltd [NC] 
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.ltd.*$ [NC] 
    RewriteRule \.(gif|jpg|js|txt)$ /messageforcurious [L]
    

提交回复
热议问题