Forums

[resolved] Hotlink protection not working (31 posts)

  1. Onzinpiet
    Member
    Posted 10 months ago #

    Hi,

    I hope you can help me with the following problem. I activated the hotlink protection option in the cpanel of my hosting company for my multisite network. Besides the multisite network (below named as 'myfirstdomain') I run another add-on domain on the same server (below named as 'mysecondaddondomain' which is located in a seperate directory: /public_html/mysecondaddondomain).

    I discovered that the hotlink function doesn't work. I've found various site using my images and bandwidth. Most of them are blogspot blogs.

    I hope you can please help me with this to discover what I do wrong or if there are errors in the (anonymized) .htaccess file below.

    Thanks a lot for your help!

    Piet.

    This is my current .htaccess file in the /public_html directory:
    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

  3. Onzinpiet
    Member
    Posted 10 months ago #

    Hi Ipstenu,

    Thanks for your information. I used a similar site before with techniques to edit my .htaccess file to obtain hotlink protection. But unfortunately with no solution.

    I'm afraid that there is something wrong/interfering with the codes in my current .htaccess file. Sorry I wasn't aware enough about the forum rules. I now used pastebin to show you the code:

    <script src="http://pastebin.com/embed_js.php?i=RCNGtEmy"></script>

    Thanks for your help.

  4. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    First put WordPress at the bottom and your hotlink at the top :)

    Then this stuff is ... you have too much repetition.

    Notic how you have *.myfirstdomain AND mail.myfirstdomain? You're duplicating efforts.

    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_REFERER}     !^$
     RewriteCond %{REQUEST_FILENAME} -f
     RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$           [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myfirstdomain\. [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myseconddomain\. [NC]
     RewriteRule \.(gif|jpe?g?|png|bmp)$                             - [F,NC,L]
    </ifModule>

    That should be ALL you need.

  5. Onzinpiet
    Member
    Posted 10 months ago #

    Thanks a lot for your advice. I'm not an expert on this, sorry for that and for asking the following.

    Can I delete all the code of my .htaccess file and replace them with the codes you gave me (putting my domain names in it)?

    In other words: do I need this content for my .htaccess:
    http://pastebin.com/embed_js.php?i=GQkST1sh

    Or the one you gave me?

  6. Onzinpiet
    Member
    Posted 10 months ago #

    Hi, I tried what you suggested me in various ways, but it didn't work. Can you please indicate me where I made an error?

    1. First I tried the following code as entire code for the file:

    <iframe src="http://pastebin.com/embed_iframe.php?i=mcwa37j2" style="border:none;width:100%"></iframe>

    2. After that I tried only the code you suggested me for the file (without WP-codes):

    <iframe src="http://pastebin.com/embed_iframe.php?i=dXSAHmMJ" style="border:none;width:100%"></iframe>

    Is this piece of code always necessary in the .htaccess file?

    <iframe src="http://pastebin.com/embed_iframe.php?i=7tsDDkiN" style="border:none;width:100%"></iframe>

    Thanks!

  7. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    Did you happen to notice how many extra slashes you have in there?

    http://pastebin.com/4681dK4p

  8. Onzinpiet
    Member
    Posted 10 months ago #

    Hi Ipstenu,
    I tried the last (pastebin) code you gave me but it doesn't work. And besides that the images of 'myfirstdomain.com' don't appear now. The ones of the seconddomain.com do appear normally.
    Is there some code lacking in the beginning of the codes?
    Thanks a lot for your help!

  9. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    You'll have to read the doc I linked to for other versions. Not all .htaccess setups are the same, and there's always experimentation.

  10. Onzinpiet
    Member
    Posted 10 months ago #

    Hi,

    I'm not an expert in this, but I tried everything that is suggested on the site you mentioned.

    I have 2 domains (the 2nd is a so called add-on domain) and the 1st has WordPress Multisite enabled (sub-directories), I don't know if that's the problem.

    I don't know if you or anybody else can offer an alternative that can help me, honestly I don't now what more I can do or where to ask for help.

    Thanks.

  11. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    Ask your webhost at this point, since they may have something set up to stop it from working. But that code is exactly what I use for my site with an add-on domain (and even for a domain that isn't even mine - I like giving my tumblr account permissions to use my images). I know the code is valid for MOST sites.

  12. Onzinpiet
    Member
    Posted 9 months ago #

    Hi Ipstenu,

    I solved the problem I had with the hotlink protection, thank you so much for your information!
    Now I tried to give permission to the translator of Google (to add it to the whitelist), but it doesn't work. I've tried the following 2 options:

    RewriteCond %{HTTP_REFERER} !^http(s)?://(www|translate)\.?google.* [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?translate.google.com/.*$ [NC]

    I can't find information about this on the Internet, do you have a suggestion to solve this?

    Thanks a lot in advance!

  13. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    What's the hotlink protection code you're using? There are a few variants.

  14. Onzinpiet
    Member
    Posted 9 months ago #

    I use this :

    http://pastebin.com/4681dK4p

    Thanks.

  15. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]

    should do it

  16. Onzinpiet
    Member
    Posted 9 months ago #

    I will try this and will inform you about it.

    Does this permit everything of Google?

    Thanks a lot!

  17. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Should, yes.

  18. Onzinpiet
    Member
    Posted 9 months ago #

    Thanks Ipstenu,
    I added it below the two domains, but it didn't work...
    Is there a way to give permission only to the translator?

  19. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Why do you need it? Google's capable of caching the images anyway (which is NOT the same as hotlinking).

  20. Onzinpiet
    Member
    Posted 9 months ago #

    You are right! Nonetheless, the code you gave me doesn't work, what can I do?

    I added it like this:

    # Hotlink Protection
    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_REFERER}     !^$
     RewriteCond %{REQUEST_FILENAME} -f
     RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$           [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myfirstdomain\. [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myseconddomain\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]
     RewriteRule \.(gif|jpe?g?|png|bmp)$                             - [F,NC,L]
    </ifModule>
  21. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    One more time. WHY do you need this?

    Google doesn't hotlink, so WHAT problem are you experiencing that makes you think THIS is the answer?

  22. Onzinpiet
    Member
    Posted 9 months ago #

    Adding Google isn't a problem for me, I only asked you a question, but my question is another: it is necessary that the images of my site are visible when someone views it with a translator.

    Like I said in the beginning, my hotlink protection works ok in .htaccess, but the Google translator doesn't work (the images can't be seen when translated), you suggested me:
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]

    I added this to the .htaccess but it doesn't work. My question is: did I put this line in the right place/position or is there another option?

    Here's the complete current code again like I added it:

    # Hotlink Protection
    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_REFERER}     !^$
     RewriteCond %{REQUEST_FILENAME} -f
     RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$           [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myfirstdomain\. [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?myseconddomain\. [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]
     RewriteRule \.(gif|jpe?g?|png|bmp)$                             - [F,NC,L]
    </ifModule>
  23. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Google translator doesn't work (the images can't be seen when translated)

    That will not be solved by adding them to your hotlinking exceptions list because, and please listen to this, GOOGLE DOESN'T HOTLINK. It doesn't matter WHAT you add to .htaccess, Google isn't hotlinking so you will NEVER be able to magically grant is access.

    I do NOT have a google exception in my htaccess and if you translate http://ipstenu.org/ oh look! Magically it works.

    So that's NOT your problem :)

    Can you give a real URL at this point?

  24. Onzinpiet
    Member
    Posted 9 months ago #

    I NEVER have said that Google does apply hotlinking!! Where did you read that?? Why do you speak to me this way?

  25. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Because you're not understanding what you're asking here.

    What you're asking us is this: How do I add Google to my anti-hotlink code so that it can link directly to my images, because google translate isn't picking up my images.

    And what I'm telling you is that because Google does NOT hotlink to your images, adding them to that code won't fix your problem.

    Does that make sense? I get that English isn't your first language, so I'm trying to explain this to you in different ways. What you're doing, adding Google to your hotlink exception rules, will not, does not and can not, solve the problem of Google Translate NOT seeing your images.

    It's not how Google works, it's not how the code you're using works, and it's just a misunderstanding. Nothing more. Once you can get past that, we can look at what actually IS wrong.

    Now. Can you provide a REAL URL, not a temp one like mydomain, so we can see what's not working?

  26. Onzinpiet
    Member
    Posted 9 months ago #

    I looked at your site and please take notice that it doesn't work for you neither!! Load your site with the translation and at first (the homepage) your images are visible, but when you open a single post, the images of that post aren't visible neither (the same thing that happens to me). Check your posts.

  27. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    I did. It works fine. See a screenshot: http://imageshack.us/photo/my-images/705/translatef.jpg/

    What browser are you using?

  28. Onzinpiet
    Member
    Posted 9 months ago #

    The first entry of your site works, but not all the entries. Check out your other/older entries. Sometimes the images of your entries are visible in the translator and sometimes they ain't.

    I tried it in Firefox and IExplorer (latest versions).

    I added some screenshots of the second page of your site:

    http://imageshack.us/photo/my-images/204/25050833.jpg/

    http://imageshack.us/photo/my-images/225/41545532.jpg/

    http://imageshack.us/photo/my-images/13/66764143.jpg/

    Which browser do you use?

  29. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    That was actually my second entry. And they ALL work for me on my browser. Every last link I click internally works fine (except when it gives a 503, which is server security and something I know that I did).

    Hotlinking, by the way, would include the header image which shows just fine.

    I use Chrome.

    But on that note, if I use anything else it fails.

    So it's not you, nor me, it's Google (and according to their docs, has been a problem since 2009).

  30. Onzinpiet
    Member
    Posted 9 months ago #

    That can be true, but before adding the hotlink protection codes to the .htaccess file the translator worked without problems...

Reply »

You must log in to post.

About this Topic