简体   繁体   English

防止在apache或Windows Server 2008中下载php文件

[英]prevent php files from being downloaded in apache or Windows Server 2008

  1. In Linux Apache, I put my php files under /var/www/html. 在Linux Apache中,我将php文件放在/ var / www / html下。 If I don't add an index.html in every subfolders under /var/www/html, Then my php files will be listed and can be downloaded. 如果我没有在/ var / www / html下的每个子文件夹中添加index.html,那么我的php文件将被列出并可以下载。

The question is must I configure the apache file in order to prevent listing of my php files and hence to prevent download of my php files ? 问题是我是否必须配置apache文件以防止列出我的php文件,从而防止下载我的php文件?

[Edited] I want the php file to be executed and produce desired web pages but the sourcecode files not to be downloaded by anyone. [编辑]我希望执行php文件并生成所需的网页,但是任何人都不要下载源代码文件。 My php files are placed under /var/www/html in a Ubuntu On AWS EC2. 我的php文件放在AWS EC2的Ubuntu的/ var / www / html下。 Then I try to do something like: type awsec2ip/mywebsiteRootDirectory/ , if there ain't an index.html, then the server lists my php files and allow me to right-click the php files and then download them. 然后,我尝试执行以下操作:键入awsec2ip / mywebsiteRootDirectory /,如果没有index.html,则服务器会列出我的php文件,并允许我右键单击php文件,然后下载它们。

[not so related to question 1]Also I want to ask if I only want my android application to run some php files for dealing with the database, where should I put the php files or how should I configure the apache? [与问题1无关]我也想问一下,我是否只想让我的android应用程序运行一些php文件来处理数据库,我应该将php文件放在哪里或应该如何配置apache?

Thanks for your help and sorry for my inexperience 多谢您的协助,也很抱歉

  1. Similarly in Windows Server 2008, what are the proper procedures to produce the same security effect? 同样,在Windows Server 2008中,要实现相同的安全效果,应采取哪些适当的步骤?

将其添加到您的Web根文件夹/var/www/html .htaccess文件中:

Options -Indexes

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

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