Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Dallas, TX
    Posts
    210

    Apache rewrite question

    When people view images directly off my server (example url below), how can I have it so they are redirected to my homepage?

    http://www.example.com/example.jpg
    My Name is Joe!
    ICQ: 280 889 133

  2. #2
    Join Date
    Apr 2004
    Location
    Australia
    Posts
    419
    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^/hotlinking-allowed
    RewriteRule ^.*$ - [L]
    
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !underscorebleach\.net [NC]
    RewriteCond %{HTTP_REFERER} !bloglines\.com [NC]
    RewriteCond %{HTTP_REFERER} !google\. [NC]
    RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
    RewriteRule (.*) /view_image.shtml?/$1
    Or just read this handy tutorial that i found via google: http://underscorebleach.net/jotsheet...taccess-apache

  3. #3
    Join Date
    Dec 2002
    Location
    Dallas, TX
    Posts
    210
    Thanks, I'll test it out tonight and see if it works.
    My Name is Joe!
    ICQ: 280 889 133

  4. #4
    Join Date
    Aug 2005
    Location
    Canada
    Posts
    838
    That rule can be written like this.

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !(underscorebleach\.net|bloglines\.com|google\.|search\?q\=cache)  [NC]
    RewriteRule !^/*hotlinking-allowed  view_image.shtml?%{REQUEST_URI}
    Also, I would simply serve blank data rather than wasting server resources for the leeching traffic.
    RewriteRule !^/*(hotlinking-allowed|blank.txt) blank.txt [L]

Related Posts from theWHIR.com

Posting Permissions

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