Forum Moderators: phranque
I have working code to allow my friendly domains access to my images. Unfriendly links serve up an alternate image.
I want to allow links self hosted pictures on ebay, but serve up an alt graphic to other auctions that aren't mine.
I have found that my auctions all contain "9753" in the item #. (no quotes, and I have randomly picked 9753, my numbers are different).
I have 2 sample links from ebay that I would like to work:
http: //cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&ih=004&sspagename=STRK%3AMESE%3AIT&viewitem=&item=975321971110&rd=1&rd=1
http: //cgi.ebay.com/Ebay_Auction_Title_W0QQitemZ975321971110QQihZ004QQcategoryZ2747QQssPageNameZWDVWQQrdZ1QQcmdZViewItem
I am completely stumped with how to match on
- ebay.com/ws/ AND 9753 in the 1st example
- ebay.com/ AND 9753 in the 2nd example
I am thinking that if I can get this to work, that all other auctions will not be able to load my images. I do realize that the 9753 could change in the future, and I that I may have to edit this # at some point.
Can anyone help me?
Thanks!
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?anotherdomain\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(cgi\).?ebay\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!(.+/)?9753.*$ [NC]
RewriteRule .*\.(jpe?g¦gif¦bmp¦png)$ - [F]
And to expand on the item #, I believe this varies based on ebay region, tool used to post, and other many factors. Many auctions begin with lots of other #s, not just the sample # I provided.
Hoping someone can tell me where I have gone awry :)
However, if someone visits my auction (& the image is cached), when the offending auction is visited, image xyz.jpg displays (as requested by the auction) instead of freebookwithpurchase.jpg, which is the replacement image for offending auctions.
Doing a Ctrl Refresh serves up freebookwithpurchase.jpg .
RewriteRule \.(gif¦jpg)$ [mydomain.com...] [R,L]
How do I expire the images so that the offending auction receives the correct image?
Thanks!
ExpiresActive on
ExpiresDefault "access plus 0 seconds"
ExpiresByType image/gif "access plus 0 seconds"
ExpiresByType image/jpg "access plus 0 seconds"
Is this the best way to accomplish what I am hoping for? Or do you see anything that should be elimintated/combined?
Thanks!
If you do wish to set your expires headers, set them to something reasonable like a day or a week, in order to reduce your server load. As it is, your server could crash if your item gets mentioned in slashdot or becomes suddenly popular.
The code posted above has a latent fault, in that it no longer allows *any* referer that does not contain your auction number. It doesn't seem to meet your desired goal of serving an alternate image. It also shows evidence of being auto-generated, and can be implemented much more efficiently and correctly like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?anotherdomain\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(cgi\.)?ebay\.com/.+item.9753[0-9]+ [NC]
RewriteCond %{REQUEST_URI} !^/free-book-with-purchase\.gif
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ http://mydomain.com/images/free-book-with-purchase.gif [R=302,L]
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
[edited by: jdMorgan at 3:45 pm (utc) on May 28, 2007]
Yes, the majority of the code was taken from some postings and tweaked. And I just was not able to implement the code for the 2 conditions for the ebay auctions, so that I could successfully host images for my auctions, but hopefully not everyone else's too. (Ebay doesn't close all offending auctions as they advertise that they do.)
As far as my alt image...it is intended to get the attention of the seller(s). More than likely, they are not aware that their ads no longer show the intended item, but that their ad now states there is a free gift with the purchase. Perhaps they'll get the point when the winners inquire about the "free gift" :)
I am very appreciative of all you experts that chipped in to help me implement the solution at hand.