对用户隐藏 PHP
有没有办法向用户隐藏我正在使用 PHP 的事实?我想这样做有两个原因:
- 1)这样地址栏中的链接看起来更干净(就像 stackoverflow 上的这里一样)
- 2)为了防止潜在的黑客立即知道要寻找什么
第 2 点是否现实,或者黑客会知道什么我还用着呢?我将 nginx 与 php5-fpm 一起使用。
Is there a way to hide the fact that I'm using PHP from my users? I wanted to do this for two reasons:
- 1) So the links in the address bar look cleaner (like here on stackoverflow)
- 2) To prevent potential hackers of knowing immediately what to look for
Is point 2 even realistic or will a hacker know what I'm using anyway? I'm using nginx with php5-fpm.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
http://eisabainyo.net/weblog/2007/ 08/19/通过-htaccess 删除文件扩展名/
http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/
除了 mod_rewrite 更改之外,还将
expose_php
设置为 false:In addition to the mod_rewrite changes, also set
expose_php
to false: http://www.php.net/manual/en/ini.core.php#ini.expose-php上面(或者也许下面)的答案提供了技术方面的信息,让我回答道德方面的信息:
不要这样做。第2点完全无效,如果有人想加害,这也阻止不了。然而,适当的安全检查会。第 1 点几乎没有任何意义,现在已经没有人再输入链接了。
The above (or perhaps below) answers give info on the technical side, let me answer the moral side:
Don't do it. Point 2 is completely invalid, if someone wants to do harm, this won't stop it. Proper security checks however will. Point 1 is meagerly valid, no one types links anymore these days.
保持 PHP 不被公众访问的最佳方法是相应地构建文件夹结构。最佳实践是将库和应用程序文件保持在公共文件夹的至少上一级,例如:
使用 htaccess 和 mod_rewrite 将请求路由到 index.php 文件,然后该文件会将请求分派到应用程序。
这样,您只有一个可公开访问的 php 文件,其中仅包含无法通过任何 url 访问的其他文件
The best way to keep your PHP hidden from public access is to structure your folders accordingly. Best practice is to keep your library and application files at least one level up from the public folder, like:
Use htaccess and mod_rewrite to route requests to the index.php file, which will then dispatch the request to the application.
This way, you only have a single php file publicly accessible, which merely includes other files not available via any url
嗯。好的
隐秘的安全性。相信我,这不会让他们放慢太多脚步。
然而,这样做的一个非常有效的原因是,您的网站不与特定的开发语言绑定。
我看到有几个人已经提到了 mod_rewrite。这是一个解决方案 - 但它是一个需要掌握的非常复杂的工具。另外,在 URL 路径中嵌入 CGI 变量时要非常小心 - 您可能会很快破坏内容。
一个简单的解决方案是将每个入口点 php 脚本(即任何不是包含/需要文件的文件)实现为“index.php”并通过其目录引用它。
或者选择您自己的文件扩展名,并将配置中对 .php 的引用替换为您的扩展名。
mmm. OK
Security by obscurity. Trust me, that's not going to slow them down much.
A very valid reason for doing this, however, is so that your website is not tie to a particular development language.
I see several people have already mentioned mod_rewrite. It's one solution - but it's a very complex tool to master. Also, be very careful about embedding CGI variables in the path of the URL - you can quickly break stuff.
A simple solution would be to implement every entry-point php script (i.e. anything with is not an include/require file) as 'index.php' and reference it by it's directory.
Alternatively pick your own file extension and replace the references to .php in the config with your extension.