开发者

Run PHP from a PNG file on lighttpd

开发者 https://www.devze.com 2023-01-12 10:35 出处:网络
I only need to do this for one file (uptime.php) and it must be requested by using uptime.png. Adding a rule for all png files in my conf开发者_StackOverflow中文版ig file would be suicide.. :PIn gene

I only need to do this for one file (uptime.php) and it must be requested by using uptime.png.

Adding a rule for all png files in my conf开发者_StackOverflow中文版ig file would be suicide.. :P


In general, it does not need to be requested by using uptime.png: you can use a .php extension. As long as your script outputs

Content-type: image/png

as the MIME type, browsers will recognise the data as an image.

However, if you really must use uptime.png for the URL, you can use a rewrite rule. For example:

url.rewrite-once = ( "^/uptime\.png$" => "/uptime.php" )

There is more information about these rewrite rules in the Lighttpd Docs::ModRewrite documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消