简体   繁体   English

使Nginx下载PHP文件而不是执行

[英]Make Nginx download PHP files instead of executing

I'm making a website where my friends and I want to be able to send files to each other, and those files might be of any extension, the problem is that if they send a PHP file, it won't download the file, but instead execute it. 我正在建立一个网站,我和我的朋友们希望能够互相发送文件,这些文件可能具有任意扩展名,问题是,如果他们发送PHP文件,它将不会下载该文件,而是执行它。

What I want to know is if there is any way to make Nginx serve the file directly instead of executing it, if it's in a specific directory. 我想知道的是,是否有任何方法可以使Nginx直接将其提供给文件而不是执行该文件(如果它位于特定目录中)。 Preferably a .htaccess, but its hosted on a VPS so I can do config files and similar aswell. 最好是.htaccess,但它托管在VPS上,因此我也可以执行配置文件和类似操作。

I don't think it's nginx issue. 我不认为这是nginx问题。 Try adding additional extension on the file, eg index.php.up . 尝试在文件上添加其他扩展名,例如index.php.up automatically add that when uploading and before hitting the server (use JavaScript). 在上传时以及在访问服务器之前(使用JavaScript)自动添加。 And before showing at the other end remove additional extension .up 并且在另一端显示之前,请删除其他扩展名.up

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

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