发送使用 .htaccess 请求的其他图像


Sending other image that the one requested using .htaccess

我的问题是:

如果我的 html 中有这样的图像

    <img src='http://someURL.com/images/image.jpg'>

不托管在我的服务器上,我可以从其他外部源发送另一个图像吗?使用 .htaccess 和 php。现在,如果我的图像存储在我的服务器上,我知道如何从任何来源发送另一张图像。因此,我想从"http://OtherURL.com/maybe/newImage.jpg"发送内容,而不是从"http://someURL.com/images/image.jpg"发送内容。

谢谢

您无法在服务器端执行此操作,因为浏览器会在不请求服务器许可的情况下直接访问外部源。

如果你愿意,你可以在客户端使用 JavaScript 来做到这一点。

编辑:jQuery示例解决方案

jQuery $("img[src=the_image_souce]").attr('src','new_src'); 不起作用