Results 1 to 4 of 4

Thread: how to test if hotlink protection works?

  1. #1
    Join Date
    Nov 2006
    Posts
    55
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default how to test if hotlink protection works?

    As the host of my site do not have the hot link protection feature available, they have directed me to a site to create one .htaccess file to enable the hotlinking protection.

    http://www.javascriptkit.com/howto/htaccess10.shtml

    Q1 : In the codes as appended below, do I need to retain the "?" before mydomain.com/?

    Q2: How do I test whether it works or not?

    Thank you.


    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg|js|css)$ - [F]

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jass View Post
    In the codes as appended below, do I need to retain the "?" before mydomain.com/?
    That depends on how your site is set up. Some sites can be accessed with a host names like example.com as well as www.example.com. The question mark is a regular expression operator that makes a part optional: it would match a Referer header that began either http://mydomain.com/ or http://www.mydomain.com/. If only one is acceptable, then change the regular expression accordingly.

    How do I test whether it works or not?
    A simple test would be to write a document that hotlinks an image from another host, if you have one. A more thorough test would involve sending requests that contain both acceptable and unacceptable Referer headers and check the response. You can do that with a telnet session. If you have a browser that implements the XMLHttpRequest object, you can use that, too.

    RewriteRule \.(gif|jpg|js|css)$ - [F]
    Is that list complete? No PNG images or JPEGs that have a .jpeg extension?

    Mike

  3. #3
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just be advised that if you open images using javascript, this condition will block IE users from opening them- neither Explorer sends "Refering-URI" header with window.open or location.href.

  4. #4
    Join Date
    Nov 2006
    Posts
    55
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Thanks to both. Greatly appreciate.

Bookmarks

Posting Permissions

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