Redirect without changing urls?
Weird question but here goes...
I have a webpage and i want to get images from another site. However i woul开发者_运维技巧d like to prevent users to knowing which site. It doesnt need to be perfect just 'good enough'. Is there a way i can write and have the browser get the image from another domain? If the user right clicks and hits view image i would like it to say mysite.com/redirect/id.jpg and not the new url. Is there a way to do this?
So far my only idea was to use WebClient to get the data from their server and send it out. But that would kill bandwidth. I dont need it to be perfectly hidden just good enough.
Use CSS background-image
style on a <div>
instead of an img
tag. Since CSS backgrounds don't respond to "right-click..Properties" like img
tags do, a casual viewer won't know the image location from right-click (although it will be visible via "view source").
If you want to prevent view-source exposure too, you can also obfuscate one step further by pointing the background-image
to a URL on your site which then redirects to the image you want. If you do this, then the only way the user will know where the image came from is to use Fiddler, Firebug, or another tool which can actually dig into the DOM or the HTTP stream. This won't perform as well as the CSS-only approach, but it's pretty cheap since you won't be tying up a thread on your server waiting for the remote server to respond.
BTW, if you're also concerned about the target site being annoyed that you're borrowing their content, be aware that the HTTP Referer:
header of clients will let the target site the URL of your site that is "borrowing" the image. It will be easy for them to cut you off if they so desire by blocking all requests from your referring site. You can of course get around this (e.g. by requesting the pages from your own client on your server) but then the site can just look up your IP addresses and block you. Moral of the story: if you want to "borrow" content from another site, keep it low-key and low-volume, because if you attract their attention you'll get banned.
Or (this is the ideal) contact the site and let them know what you're doing and work out an arrangement so they won't block you if your site becomes popular!
Use src=mysite.com/redirect/id.jpg
in your img
tag, and serve the mysite.com/redirect
URL by proxying for whatever other site you're stea^H^H^H^Hmashing up from.
apache's ProxyPass does that. in IIS, ARR can achieve the same thing. or you can easily just create a page that downloads the image like you said and dumps it out. but indeed, if the script were to just do a redirect, the properties would still show the final address.
you could disable right-click on images, but course it wouldn't stop a determined person.
精彩评论