#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    Hi,

    I'm trying to make a rule for images so that they always appear with a banner. The problem is that it isn't working like it should and I was actually hoping someone could help me out. I use the following:

    ################################################################
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://212.64.58.122/carmacity/.*$
    RewriteRule ^.*(.jpg)$ /carmacity/images/showimage.cgi
    ################################################################

    With this rule images show up together with a banner when the image isn't requested from http://212.64.58.122/carmacity/.*$ but only if you refresh one time. First time it's broken. And, when you click on a link from within the domain the image shows up without the banner.

    What I actually want is that all images except when they are requested from within a .gc script they appear normally as inline images. But when you click on a image to view the bigger version it should appear with the banner.

    I've been trying it for 2 days now and I just can't work it out.
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    1) For 1st visit to your http://212.64.58.122/carmacity/, do you want the images to be broken?
    2) Under what circumstances should a banner appears?
    3) When should images be broken?
    4) As per your RewriteRule, I see you just want .jpg extension to internally directing to showimage.cgi. How about .gif? .jpeg? Or is there a directory that keeps all your secret images separately from your regular images that you want to hide from or force a banner?
    5) Assuming a visitor doesn't need to refresh once and he's already at your site. Should he sees everything normally and without a banner?

    >>when they are requested from within a .gc script

    What .gc script? What does it do?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    a .gc script is just a php script with other extension
    Anyways, I've managed to fix most of the rule and I just use the rule in the directory that needs to be 'protected'. Now the images should always appear together with a banner and a link back the site.
    I'm now using this ruleset:

    #######################################################################
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$
    RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc
    #######################################################################

    The referer is use to prevent the ruleset to loop. Now have the following problem...
    Whenever you want to view a image it appears to be broken the first time, when you refresh the image will appear.
    What am I doing wrong here? Why doesn't the image show the first time?

    Thanks
  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>Now the images should always appear together with a banner and a link back the site.
    >>Why doesn't the image show the first time?
    Are you sure? A direct request to http://212.64.58.164/carmacity/images/showimage.gc gets a banner on top but a broken image at the bottom.

    I sort of but not entirely get your idea.

    >>RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc

    Why don't you pass your catch-all jpg name or preferably ([A-Za-z0-9_]+).jpe?g$ to your showimage.gc script?

    Is it true that the jpg preview page will _always have the banner on top_ while the full-size jpg page will not?

    If you can answer my 5 questions previously, maybe I can come up with a rewritten rulesets.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    Okay here we go then:

    1) For 1st visit to your http://212.64.58.122/carmacity/, do you want the images to be broken?
    That doesn't apply anymore I think as the ruleset is only active in the screenshots directory now

    2) Under what circumstances should a banner appears?
    Always.

    3) When should images be broken?
    Never, they should just appear together with the banner.

    4) As per your RewriteRule, I see you just want .jpg extension to internally directing to showimage.cgi. How about .gif? .jpeg? Or is there a directory that keeps all your secret images separately from your regular images that you want to hide from or force a banner?
    All screenshots are jpegs with the .jpg extension and they should always appear together with a banner.

    5) Assuming a visitor doesn't need to refresh once and he's already at your site. Should he sees everything normally and without a banner?
    The visitor should always see the image together with a banner. No matter were he comes from (if the referer is not http://212.64.58.164/carmacity/.* the referer is logged)

    The ruleset is kinda working but somehow you always need to refresh the page before the screenshot shows.
    http://212.64.58.164/carmacity/image.../HiRise002.jpg is an example (may not work if I got disconnected as this is running from my own pc right now). You'll probably get a broken image first and after you refresh the screenshot will appear.
  10. #6
  11. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>http://212.64.58.164/carmacity/images/tdr/screenshots/big/HiRise002.jpg is an example

    There are subdir in /images too?

    I wonder what codes you have in your showimage.gc since the problem seems to come from there. BTW, have you tried to relocate your showimage.gc to some other dir?
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    Yeah. The file .htaccess with the ruleset is in http://212.64.58.164/carmacity/image...reenshots/big/

    Changing the location of showimage.gc doesn't matter as the problem is still there. I noticed that when you click on the link to the image here it shows up the first time but that could be different for other users as it doesn't show the first time if there's no referer.

    I would think my code for showimage.gc looks normal too:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><?
    require("../styles/default.gc");
    $image = "$REQUEST_URI";
    echo"
    <html>
    <head>
    <title>Carmageddon City: Images</title>
    <style>
    body { text-decoration:none;font-family:Tahoma;font-size:10pt;color:#C0C0C0; }
    a:link { text-decoration:none;font-family: Tahoma;color:#FF5400 }
    a:visited { text-decoration:none;font-family: Tahoma;color:#FF5400 }
    a:hover { text-decoration:none;font-family:Tahoma;background-color:#870000;color:#FFBA01 }
    </style>
    </head>
    <body text="#C0C0C0" bgcolor="#3C3C3C">
    <center>
    <!-- ---------- Advertising.com Banner Code -------------- -->
    <SCRIPT LANGUAGE="JavaScript" SRC="http://servedby.advertising.com/site=7923/bnum=65325232">
    </SCRIPT>
    <NOSCRIPT>
    <A HREF="http://servedby.advertising.com/click/site=7923/bnum=65325232" target="_top">
    <IMG SRC="http://servedby.advertising.com/site=7923/bnum=65325232/bins=1/rich=0" border="0" alt="Click to learn more..."></A>
    </NOSCRIPT>
    <!-- ---------- Copyright 2000, Advertising.com ---------- -->
    <br>
    <img src="$image"><br>
    <br>
    <a href="$siteloc">Back to Carmageddon City</a>
    </center>
    </body>
    </html>
    ";
    ?>[/code]

    I'm for almost 100% sure there's something wrong with the ruleset.
  14. #8
  15. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    The problem lies with a wrong logic of HTTP_REFERER.

    (1) Your Cond:
    RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$

    As long as the http_referer doesn't match the above URL, follow the rule.

    (2) Your Rule:
    RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc

    Match any jpg request and internally redirect to /carmacity/images/showimage.gc

    >>I'm for almost 100% sure there's something wrong with the ruleset
    (3) From within your showimage.gc script, this line -> <img src="$image"> is the problem. Such line doesn't send a http_referer of http://212.64.58.164/carmacity/images/.*$
    Instead, it sends THE SAME HTTP_REFERER from your original request destination, which doesn't meet the RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$ and causing a looping. That is, re-read your RewriteCond again.

    (4) After the page stops, when you refresh it, this time, you are sending a correct http_referer which match ^http://212.64.58.164/carmacity/images/.*$, therefore, it doesn't follow the RewriteRule any longer and display the image in place.

    Once again, this -> <img src="$image"> sends a http_referer which is not what you think it is from within http://212.64.58.164/carmacity/images/.*$
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    So.... What should I use then as rewrite condition?
  18. #10
  19. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^/carmcity/images/showimage.gc$
    RewriteRule ^(.+) - [F]
    RewriteCond %{REQUEST_URI} ^/carmcity/images/([^/A-Za-z0-9]+).jepg$
    RewriteRule ^.*.jpeg$ /carmacity/images/showimage.gc?$1 [T=application/x-httpd-php]

    Your script:
    $image = "$QUERY_STRING";

    <img src="$image.jpg"><br>

    So basically you need to rename the image extension of your LINK to jpeg so the <img src="$image.jpg"><br> line doesn't match your 2nd RewriteCond.
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    6
    Rep Power
    0
    But then it has no real use anymore. People can still link to the image then as they just do a right click > properties and they know the real name of the image.
    The whole point was that when people linked to the images stored on our server that the images would appear together with a banner.
  22. #12
  23. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Then change to the following:

    #############################################
    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^/carmcity/images/showimage.gc$
    RewriteRule ^(.+) - [F]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/.*$ [NC]
    RewriteRule .*.jpe?g$ - [F]
    RewriteCond %{REQUEST_URI} ^/carmcity/images/([^/A-Za-z0-9]+).jepg$
    RewriteRule ^.*.jpeg$ /carmacity/images/showimage.gc?$1 [T=application/x-httpd-php,L]
    #############################################

    At least they can't directly typing your image to the browser location bar and get it displayed so that your image is not Getrightable.

    [This message has been edited by freebsd (edited September 24, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo