我想显示一些图像从其他网站,但我想我自己的服务器网址,而不是存储在我的一端。
在代码中,我这样写道
<img src="http://image.com/ab.gif"/>但在bowser源码上显示为
<img src="http://mysite.com/ab.gif"/>发布于 2010-01-05 15:47:34
你可以让你的脚本重定向:
<?php
$image = $_POST['image'];
$url = lookup($image);
header('Location: ' . $url);
exit;其中,lookup()是您编写的用于从数据库或平面文件中查找URL的函数。假设脚本名为image.php,那么您的URL将如下所示:
http://yourdomainname.com/image.php?image=kitten1234其中kitten1234是映像ID。
您甚至可以使用mod_rewrite重写URL并删除image.php部件。
发布于 2010-01-05 16:13:35
不是PHP的回答,但是如果你在运行Apache的时候激活了mod_rewrite和mod_proxy,你可以把文件夹从一台服务器软链接到另一台服务器。在.htaccess文件中插入以下内容:
RewriteEngine on
^/somepath(.*) http://otherhost/otherpath$1 [P]调用http://yourhost/somepath/kittens.jpg实际上会显示http://otherhost/otherpath/kittens.jpg,而不会泄露原始地址。
发布于 2010-01-05 18:00:38
您可以在Apache中使用mod_rewrite:
RewriteEngine On # Turn on the rewriting engine
# Redirect requests for images/* to images/* on anothersite
RewriteRule ^images/(.+)/?$ http://anothersite/images/$1 [NC,L]这会将所有对http://yoursite/images/anyimage.jpg的请求重定向到http://anothersite/images/anyimage.jpg。
https://stackoverflow.com/questions/2004636
复制相似问题