Results 1 to 14 of 14

Off-Topic HTACCESS Help Needed (Hotlinking)

This is a discussion on Off-Topic HTACCESS Help Needed (Hotlinking) within the General Discussion forums, part of the vBulletin SEO Discussion category; I have a watermark script that I wrote that will watermark on the fly. I now want to watermark any ...

  1. #1
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times

    Off-Topic HTACCESS Help Needed (Hotlinking)

    I have a watermark script that I wrote that will watermark on the fly. I now want to watermark any external image requests. Here is what I added to .htaccess:
    Code:
    #RewriteCond %{HTTP_REFERER}   !^http://www\.nationofblue\.com/$   [NC]
    #RewriteCond %{HTTP_REFERER} !^$
    #RewriteRule ^(.*)\.(gif|jpg|png)$ watermark.php?img=$1\.$2   [R]
    The problem with this is that any image on my site, not using the full domain, is also watermarked. How do I stop this?

  2. #2
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    There will always be a referrer....

    Make sure you case them all


    RewriteCond %{HTTP_REFERER} !^http://domain.biz/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://domain.biz$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.domain.biz/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.domain.biz$ [NC]

  3. #3
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Hey Brian,

    I am not exactly sure what you mean. In this example (which is in my .htaccess above all vbseo directives) I have the the referrer defined:
    Code:
    #RewriteCond %{HTTP_REFERER} !^$
    #RewriteCond %{HTTP_REFERER} !^http://www\.nationofblue\.com/$   [NC]
    #RewriteRule ^(.*)\.(gif|jpg|png)$ watermark.php?img=$1\.$2   [L]
    (of course am not commenting the lines out when testing...)

  4. #4
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    Code:
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://nationofblue.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://nationofblue.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.nationofblue.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.nationofblue.com$      [NC] 						
    RewriteRule ^(.*)\.(gif|jpg|png)$ watermark.php?img=$1\.$2   [L]

  5. #5
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    I'll give it a whirl. Thanks!

  6. #6
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Hey Brian,

    Ok, that seems to work but I have another problem.

    I want to redirect:
    http://www.nationofblue.com/uk_ul_rivalry.jpg

    to:
    http://www.nationofblue.com/watermar...ul_rivalry.jpg

    Is the code we're using above correct to do that?

  7. #7
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    It looks correct... it should catch all images.

  8. #8
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Hey Brian,

    I appreciate all your help with this but for some reason the redirect is not working.

    Basically, I would want:
    http://www.nationofblue.com/content/...ne-behanan.jpg

    Redirected to:
    http://www.nationofblue.com/watermar...ne-behanan.jpg

    The watermark.php script works fine but when I uncomment the directives you listed for htaccess all I get is a broken image.

  9. #9
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    You may need to use the REAL path, not the vbseo'ed path, to the iamge.

  10. #10
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Yeah I thought that too. Both examples I have linked above are the real paths to the image though. I am totally stumped here. You would think that would be a simple rewrite.

    How could I set it up to rewrite it when I was accessing the image directly in a browser for testing purposes?

  11. #11
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Brian,

    Could you flag this for Oleg to get his expertise on the rewrite? Something is fundamentally missing as the request is not being redirected to the new URL.

  12. #12
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Posting an image for testing purposes.




  13. #13
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    seems to be working...

  14. #14
    Senior Member
    Real Name
    kyrivalry
    Join Date
    Nov 2009
    Posts
    103
    Liked
    0 times
    Hey Brian,

    I just got it working. for the rewrite line, I have to include the full URL. AWESOMENESS!!! Thanks for all your help.

Similar Threads

  1. htaccess file - what's needed
    By aacircle in forum Troubleshooting
    Replies: 3
    Last Post: 10-15-2009, 09:55 PM
  2. rewrite/htaccess - help needed.
    By ceho in forum URL Rewrite Settings
    Replies: 0
    Last Post: 08-30-2009, 01:55 PM
  3. Help with .htaccess needed
    By cykelmyggen in forum URL Rewrite Settings
    Replies: 3
    Last Post: 01-30-2009, 05:55 PM
  4. Non-vBSEO .htaccess Help Needed
    By Keith Cohen in forum General Discussion
    Replies: 3
    Last Post: 03-09-2006, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •