如何保护PHP文件的.htaccess从与PHP5下载坠毁

编程入门 行业动态 更新时间:2024-10-17 11:29:32
本文介绍了如何保护PHP文件的.htaccess从与PHP5下载坠毁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

昨天晚上,我做了一些管理员更改我的网络服务器。我使用PHP。 PHP的处理器不能在更新后,如果有人来到我的主页,PHP页面将只需下载并显示在专用的code和密码给任何人参观。所以我在想,如果有一种方法,以prevent使用的.htaccess任何形式的下载PHP文件 - 但仍然允许文件的正常观看

Last night I made some admin changes to my webserver. I use php. The php processor failed after the update and if someone went to my homepage, the php page would simply download and show the proprietary code and password to anyone visiting. So I was wondering if there is a way to prevent any form of download for php files using .htaccess -- but still allow for normal viewing of the files.

推荐答案

一个很好的模式在开发过程中,遵循的是用最少的初始化文件,它调用驻留在根目录以外的实际应用。只有这样,没有关键信息的最小存根在这样的情况下被暴露出来。

A good pattern to follow during development is to use a minimal initialization file, which invokes the actual application which resides outside the webroot. That way only a minimal stub with no critical information is exposed in a case like this.

简单的例子:

/ /app critical_code.php /webroot .htaccess <- rewrites all requests to index.php index.php <- invokes ../app/critical_code.php (or other files as requested)

更多推荐

如何保护PHP文件的.htaccess从与PHP5下载坠毁

本文发布于:2023-11-01 12:59:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   PHP   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!