Good day.
There was a problem with htaccess when enabling image protection from use from other domains. Here are some of the lines in the file:

#ерунда всякая RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www.)?domain\.com [NC] RewriteRule \.(jpg|jpeg|gif|png)$ - [F,L] RewriteBase / #далее - код от CMS'ки 

At the same time, the CMS works, but the images are quietly displayed on other domains. How to fix it? Thank you in advance.

Updated
<a href="http://domain.com/img/img.jpg"><img src="http://domain.com/img/img.jpg"></a>
As I understand it, neither the picture should be displayed, nor the link should not lead to it. Right?

  • Doesn't the HTACCESS syntax mean “not doing anything”? Maybe I am certainly wrong, but try replacing the RewriteRule with something like: RewriteRule \. (Jpg | jpeg | gif | png) $ domain.com [R, L] - Dobby007
  • In the same place flag [F] - in theory, the status should be issued Forbidden. Made your way. The same story. = ( - ling
  • one
    @ling dig out the answer, plz throw off ... Rakes need to be stored! - Palmervan
  • Does the rest of htaccess work then? That concerns cms'ki. Can Htaccess on the server just simply be disabled? - Dobby007
  • @Palmervan, required. =) - ling

2 answers 2

 RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?domain.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L] 
  • The same story. And the pictures can be set from other domains, and the transition to the link to the picture occurs. Maybe you need to comply with some conditions that I do not know? - ling
  • Apparently it is necessary ... about which I also don `t know ... I looked at the result of this question vs the answer to a dozen forums, almost the same everywhere, although the rule has been lying around for a long time ... xs, can the wafer hoster? - Palmervan
  • for the question zaplusadinil, why doesn’t it work? .. - Palmervan

Try this:

 RewriteEngine on RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www.)?site\.com/ [NC] RewriteRule (.png|.gif|.jpg|.jpeg)$ / [F,L] 

At least, I checked it on my locale, everything works. If something is wrong, then most likely this hoster is to blame.

  • I have a locale and mine works! The darkness is visible in the other! - Palmervan