简体   繁体   English

在.htaccess中将.php欺骗为.png?

[英]Spoof .php as .png in .htaccess?

I created a dynamic image script in PHP but I want to show it as .png . 我用PHP创建了一个动态图像脚本,但我想将其显示为.png

What is the .htaccess configuration to type domain.com/image/image.png and return the content of domain.com/image/image.php ? 键入domain.com/image/image.png并返回domain.com/image/image.php内容的.htaccess配置是什么?

Assuming your .htaccess file is placed at your web root, give this a try: 假设您的.htaccess文件位于网络根目录下,请尝试以下操作:

RewriteEngine On
RewriteRule ^image/image\.png image/image.php [L]

Alternatively, you can name a directory "image.png" then place an index.php file in there thus: image/image.png/index.php . 或者,您可以命名目录“ image.png”,然后在其中放置一个index.php文件: image/image.png/index.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM