解析巴布亚新几内亚通过htaccess的PHP仅适用于本地服务器,但不是在网络服务器 [英] Parsing PNG as PHP via htaccess works only on local server but not on webserver
问题描述
我创建了一个动态的PNG图像在PHP。为了使用PNG扩展我创建了一个的.htaccess-文件,其内容如下:
I have created a dynamic PNG-picture in PHP. In order to use the PNG extension I created a .htaccess-File with the following content:
AddType application/x-httpd-php .png
在我的本地XAMPP服务器一切都运行完美,但上载在一个网络服务器中的文件后,它不了科技工作。当我访问该文件,显示文件的PHP的code。
这是来自两个服务器的2个不同的答案:
本地服务器:
On my local XAMPP server everything works perfect, but after uploading the files on a webserver it doesn' t work anymore. When I access the file, the PHP-Code of the file is displayed.
These are the 2 different answers from both servers:
Local Server:
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2012 21:51:58 GMT
Server: Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
Last-Modified: Sat, 07 Feb 2009 11:47:04 GMT
Etag: "9000000024598-1e66-46252b23c9e00"
Accept-Ranges: bytes
Content-Length: 7782
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: image/x-icon
网络服务器:
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2012 21:55:17 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r
Last-Modified: Tue, 16 Oct 2012 21:21:56 GMT
Etag: "db0f1b0-afc-4cc33be6befa5"
Accept-Ranges: bytes
Content-Length: 2812
Keep-Alive: timeout=3, max=100
Connection: Keep-Alive
Content-Type: application/x-httpd-php
所以,不知何故该文件没能坐解析。我真不'吨知道从哪里开始在这里。
So somehow the file doesn' t get parsed. I really don' t know where to start here.
推荐答案
我想你最好使用的.htaccess
通过这样的RewriteEngine叙述:
I think you'd better use a .htaccess
with the RewriteEngine like this :
RewriteEngine On
RewriteBase /directory/to/dynamic_image
RewriteRule ^logo\.png$ logo.php
或所有PHP文件:
Or for all .php files :
RewriteEngine On
RewriteBase /directory/to/dynamic_image
RewriteRule ^(.+)\.png$ $1.php
这篇关于解析巴布亚新几内亚通过htaccess的PHP仅适用于本地服务器,但不是在网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!