Forum Moderators: phranque
I have a person linking to my images on my server on eBay.
The other problem is that I use eBay as well, so I can't just block all of the eBay HTTP_REFERER traffic.
I want to block one specific auction to put up an image that I have created.
So if the referrer string has the pattern 123456789 in the URL, it will serve all images with my redirected image.
This is what I have so far:
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?ebay\.com/ [NC]
RewriteCond %{HTTP_REFERER} ^123456789.*$ [NC]
RewriteRule \.(gif¦GIF¦jpg¦JPG)$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L,R]
It's obviously not working.
Line one was to match traffic from ebay.
Line 2 was to match the item id pattern in the HTTP_REFERER string.
Line 3 is the image I want them to be served.
What did I do wrong?
From all the info I've looked at, this should be working, but it's not:
RewriteCond %{HTTP_REFERER} (^.*$)123456789(^.*$) [NC]
RewriteRule \.(gif¦GIF¦jpg¦JPG)$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L,R]
In the above, I only want the string "123456789" to be present in the page the image is going to be served on. If it is, line 2 serves the image of death.
Well, I tried this with no success:
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?ebay\.com/ [NC]
RewriteCond %{HTTP_REFERER} 123456789.*$ [NC]
RewriteRule \.(gif¦GIF¦jpg¦JPG)$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
and this, without success either:
RewriteCond %{HTTP_REFERER} (^.*$)123456789(.*$) [NC]
RewriteRule \.(gif¦GIF¦jpg¦JPG)$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
However, in the 1st of 2 examples just mentioned here, the offending auction gets served broken image boxes, and my good auction is still working. So I know something's on the right track.
RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?ebay\.com/ [NC]
RewriteCond %{HTTP_REFERER} 123456789
RewriteRule \.(gif¦GIF¦jpe?g¦JPE?G)$ /images/imagetheft/170261407400.gif [L]
I have made a number of amendments. I'd be surprised if it didn't work now.
Make sure you flush your browser cache, before testing.
RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*ebay\.com/ [NC]
RewriteCond %{HTTP_REFERER} 123456789
RewriteCond %{REQUEST_URI} !^/images/imagetheft/170261407400\.gif$
RewriteRule \.(gif¦jpe?g)$ /images/imagetheft/170261407400.gif [NC,L]
You must completely flush your browser cache before testing new code, and after any successful load of your images. For example, if you browse to one of your other auctions --one that this rule does not block-- then your browser will cache the image. If you then browse to the auction where image loading is blocked by this rule, then your browser will show you the image from its cache, and won't send a request for that image to the server. So, since no request is sent, and the image is served from your local browser cache, it will appear that the rule isn't working unless you flush out your browser cache.
Important: Change the broken pipe "¦" character in the RewriteRule pattern to a solid pipe before use; Posting on this forum modifies the pipe character.
Jim
I had it working with this clumsy piece earlier today:
#RewriteCond %{HTTP_REFERER} .*170261407400.* [NC]
#RewriteRule .*\image_1\.gif$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
#
#RewriteCond %{HTTP_REFERER} .*170261407400.* [NC]
#RewriteRule .*\image_2\.gif$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
#
#RewriteCond %{HTTP_REFERER} .*170261407400.* [NC]
#RewriteRule .*\image_3\.gif$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
#
#RewriteCond %{HTTP_REFERER} .*170261407400.* [NC]
#RewriteRule .*\image_4\.gif$ http://www.mydomain.com/images/imagetheft/170261407400.gif [L]
I have since switched to the 4 line code jdMorgan has listed here.
The explanations here help me understand what is happening.
Thanks so much everybody.