.htacces and full page instead of hotlinked image

Discussion in 'Site & Server Administration' started by Sipifi, Feb 7, 2008.

  1. #1
    Hello,

    I was wondering if it was possible to make for example: http://www.domain.com/images/image.jpg go to http://www.domain.com/image.php?id=image.jpg

    I saw something like this on the forum:

    If (request full_image AND TYPE =IMAGE) THEN
    REDIRECT TO image.php?id=requested_file.
    Code (markup):
    But that won't work. So if someone has any suggestions, i'm all ears (eyes :p)

    Thanks a lot in advance :)

    And i did try searching google already, but that just gave me the hotlink prevention i already knew.
     
    Sipifi, Feb 7, 2008 IP
  2. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #2
    You can use a rewrite rule such as this:

    RewriteRule  ^/(*.jpg)     http://www.domain.com/image.php?id=$1
    Code (markup):
     
    boltok, Feb 7, 2008 IP
  3. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #3
    Hey, thanks for the reply.

    I did try that:

    RewriteRule  ^/(*.jpg)     http://www.sipifi.com/image.php?id=$1
    Code (markup):
    That gives me an internal server error. I have that .htacces file in the images folder and here's the .htacces:

    <IfModule mod_rewrite.c>
    AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi .htaccess 
    Options -ExecCGI
    
    RewriteRule  ^/(*.jpg)     http://www.sipifi.com/image.php?id=$1
    
    </IfModule>
    Code (markup):
     
    Sipifi, Feb 7, 2008 IP
  4. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #4
    I know it hasn't been long since i started this, but does anyone have an idea? :( i tried some others too, same result.

    I tried putting a shtml file in the image dir

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Sipifi.com image</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    	@import url(/css/common/);
    </style>
    </head>
    
    <body>
    
    <p align="center"><img src="<!--#echo var="query_string" -->" alt=""></p>
    <p align="center">This image is from Sipifi, <a href="www.sipifi.com" title="Home page of Sipifi.com">sipifi.com</a>.<br>
    Feel free to look around the site.</p>
    
    <p align="center">The permanent link to this image is:<br>
    <a href="http://www.sipifi.com<!--#echo var="query_string" -->" title="Use this URL for linking or bookmarking" class="small-text">http://www.sipifi.com
    <!--#echo var="query_string" --></a></p>
    
    </body>
    </html>
    HTML:
    And in the .htacces file would be:

    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !sipifi\.com [NC]
    RewriteCond %{HTTP_REFERER} !apifi\.com [NC]
    RewriteCond %{HTTP_REFERER} !google\. [NC]
    RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
    RewriteRule (.*) /view_image.shtml?/$1 [R,NC,L]
    
    Code (markup):
    After doign this i didn't even get a internal server error. Hotlinking would still work on any site.
     
    Sipifi, Feb 7, 2008 IP
  5. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #5
    Anyone? Could really use some help.
     
    Sipifi, Feb 8, 2008 IP
  6. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,121
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #6
    ColorWP.com, Feb 9, 2008 IP
  7. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #7
    Thanks a lot. I found what i needed! So weird i didn't find that whilst searching :)
     
    Sipifi, Feb 9, 2008 IP