Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Configuration 如何在lighttpd中下载php文件_Configuration_Lighttpd - Fatal编程技术网

Configuration 如何在lighttpd中下载php文件

Configuration 如何在lighttpd中下载php文件,configuration,lighttpd,Configuration,Lighttpd,我需要允许用户从我的网站下载一个php文件。 web服务器是lighttpd 我认为网站本身是用php编写的,所以在浏览器中呈现一个带有php扩展名的普通文件 如何只提供一个特定的php文件供下载,这样当用户单击链接时,下载将开始,而不是呈现文件 我不想将该文件压缩为一种解决方法,我希望用户能够下载该php文件 有人知道lighttpd的正确配置指令吗?将其重命名为txt,或者,使用另一个PHP脚本将PHP代码打印给用户。理论上,您应该能够通过以下方式从同一目录中使用不同的PHP执行此操作: $

我需要允许用户从我的网站下载一个php文件。 web服务器是lighttpd 我认为网站本身是用php编写的,所以在浏览器中呈现一个带有php扩展名的普通文件

如何只提供一个特定的php文件供下载,这样当用户单击链接时,下载将开始,而不是呈现文件

我不想将该文件压缩为一种解决方法,我希望用户能够下载该php文件


有人知道lighttpd的正确配置指令吗?

将其重命名为txt,或者,使用另一个PHP脚本将PHP代码打印给用户。

理论上,您应该能够通过以下方式从同一目录中使用不同的PHP执行此操作:

$your_file = file_get_contents('script.php');
header('Content-Type: application/txt');
header('Content-Disposition: attachment; filename="script.php"');
header('Content-Length: ' . strlen($your_file));
echo $your_file;

让我知道它是否有效。

但这只会在页面上显示为纯文本文件。我正在寻找一种方法,以某种方式修改标题中的内容类型,从而触发浏览器中的下载