可以在php中创建一个脚本,用于img标记中显示图像,例如:
<img src="http://domain.com/img.php?id=1" />
当被调用时,脚本计算印象(这里没有问题),并在结尾返回gif/jpg格式的图像。
现在我使用:
header( "Content-type: " . $type );
readfile( $img );
它工作得很好,但不会返回gif/jpg格式的图像文件。。
当我键入domain.com/img.php?id=1在浏览器中,浏览器地址应更改为domain.com/image.gif
这有可能吗?
这是可能的
只需使用htaccess重写代码来隐藏php地址
您可以在.htaccess文件上尝试此代码
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^*(.*).gif$ img.php?id=$1 [L]
Options All -Indexes
</IfModule>
它会改变img.php吗?id=XXX到XXX.gif(不是真实的图像文件,只是为了屏蔽真实地址)