我有一个动态图像脚本,使用此标记显示图像上的用户信息
<img src="http://domain.com/dynamicimage.php" />
使用.hatccess?
以任何方式将.PHP
更改为.PNG
答案 0 :(得分:0)
您无需为此更新.htaccess。 如果你不介意src属性中的.php扩展名,你可以简单地确保php脚本为png内容生成正确的标题。例如:
header('Content-Length: '.strlen($imgesrcstring));
header('Content-Type: image/png');
如果您注意.php扩展名,则需要在.htaccess中添加一些内容以进行重写设置,以便dynamicimage.php处理对dynamicimage.png的任何请求
在这种情况下,请看一下这个问题:
答案 1 :(得分:-1)
启用mod_rewrite
和.htaccess
到httpd.conf
,然后将此代码放在.htaccess
DOCUMENT_ROOT
目录下:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(dynamicimage)\.php$ /$1.png [L,NC,R=301]