0

我有一个小问题。我有一个图像的颜色自定义代码,我使用 RewriteRule 使它更短:

RewriteRule ^cc-(.*?)-(.*?)\.png$ cc.php?col1=$1&col2=$2 [L]

当我输入 localhost/Gen/cc-1122ff-ffffff.png 时,它通常会为我打开。但是,当我想用​​ PHP 向这个生成的图片添加文本时,我使用另一个 RewriteRule:

RewriteRule ^sig,(.*?),(.*?),(.*?),(.*?),([^,]+),(.*?),([^,]+)\.png$ test.php?nam=$6&font=$5.ttf&bg=$7.png&gn=$1&badg=$2&typ=$3&itm=$4 [L]

我去这个链接: localhost/Gen/sig,y,y,mem,no,Pixel,test,cc-1122ff-ffffff.png 我得到这个错误:

Warning: imagecreatefrompng(cc-1122ff-ffffff.png): failed to open stream: No such file or directory in D:\Xampp\htdocs\Gen\test.php on line 31

第二个 RewriteRule 通常适用,例如 localhost/Gen/sig,y,y,mem,no,Pixel,test,white.png 第二个 RewriteRule 不适用于第一个 RewriteRule。为什么?

4

1 回答 1

1

imagecreatefrompng当 URL 是相对的(如 )时不发出 HTTP 请求cc-1122ff-ffffff.png;它将其视为文件路径。

如果您将 URL 设为绝对 URL,例如localhost/Gen/sig,y,y,mem,no,Pixel,test,http%3A%2F%2Flocalhost%2FGen%2Fcc-1122ff-ffffff.png, imagecreatefrompng 会将其视为 URL,而不是文件路径。

于 2012-10-10T18:36:19.330 回答