Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 显示其他服务器的图像和浏览器上的路径显示应为矿山服务器_Php_Apache_Apache Config - Fatal编程技术网

Php 显示其他服务器的图像和浏览器上的路径显示应为矿山服务器

Php 显示其他服务器的图像和浏览器上的路径显示应为矿山服务器,php,apache,apache-config,Php,Apache,Apache Config,我想显示一些来自其他网站的图片,但我希望我自己的服务器url不存储在我的最后 在代码中,我是这样写的 <img src="http://image.com/ab.gif"/> 但在bowser源上显示为 <img src="http://mysite.com/ab.gif"/> 您可以让脚本重定向: <?php $image = $_POST['image']; $url = lookup($image); header('Location: ' . $ur

我想显示一些来自其他网站的图片,但我希望我自己的服务器url不存储在我的最后

在代码中,我是这样写的

<img src="http://image.com/ab.gif"/>

但在bowser源上显示为

<img src="http://mysite.com/ab.gif"/>

您可以让脚本重定向:

<?php
$image = $_POST['image'];
$url = lookup($image);
header('Location: ' . $url);
exit;
其中,
kitten1234
是图像ID


您甚至可以使用mod_rewrite来重写URL并删除image.php部分。

不是php答案,但是如果您在mod_rewrite和mod_代理激活的情况下运行Apache,您可以创建一种从一台服务器到另一台服务器的文件夹软链接。 将其插入.htaccess文件:

RewriteEngine on
^/somepath(.*) http://otherhost/otherpath$1 [P]

实际上,来电显示时不会显示原始地址。

您可以这样做:

<img src="data:image/gif;base64,<?php echo base64_encode(file_get_contents("http://www.qweas.com/downloads/graphic/animation-tools/scr-coffeecup-gif-animator.gif")); ?>" />
“/>
这将获取图像并将其显示为内联数据,它将不会作为URL提供,但它将位于您的站点上(如果您想禁用显示原始URL-s)

您可以做的另一件事是使用mod_rewrite强制每个图像查找到一个php脚本。
在该脚本中,您可以使用一组图像(或查询数据库)作为原始图像url并用php显示。这有点复杂,需要您为站点上的每个图像输入原始图像url。

您可以在Apache中使用mod_重写:

RewriteEngine On # Turn on the rewriting engine
# Redirect requests for images/* to images/* on anothersite
RewriteRule ^images/(.+)/?$ http://anothersite/images/$1 [NC,L]

这将把对的所有请求重定向到。

Why-1?它在IE中工作,而不是在旧版本5和6中。此外,我还指定了另一个选项。
RewriteEngine On # Turn on the rewriting engine
# Redirect requests for images/* to images/* on anothersite
RewriteRule ^images/(.+)/?$ http://anothersite/images/$1 [NC,L]