.htaccess 拒绝访问文件夹
我是 apache 的新手...所以请对我温柔一点:-)
我已经使用以下内容来拒绝使用 .htaccess 访问 Web 文件夹:
order deny,allow
deny from all
我收到了“禁止”页面,这没关系,因为我不'不希望网络用户、蜘蛛或抓取工具访问此文件夹。
但我无法再通过我编写的 php 脚本访问 web 文件夹。我认为应用程序对此有例外。
这个新手将不胜感激任何帮助...
谢谢...
I'm new to apache... so be gentle with me guys :-)
I have used the following for denying access to a web folder with .htaccess:
order deny,allow
deny from all
I'm getting the "forbidden" page which is ok because I don't want web users, spiders or scrapers to access this folder.
But I am no longer able to access web folder though php script that I have written. I thought that the applications where an exception to this.
Any help would be greatly appreciated by this newbie...
Thx...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能是错的,去 myipaddress.com 或其他地方检查你的 IP 地址。然后您可以
拒绝所有
并允许<您的IP>
I might be wrong , go to check your ip address with myipaddress.com or whatever. Then you can
deny from all
andallow from <YOUR IP>
您可以尝试使用 HTTP 基本身份验证来保护您的文件,但通过在 PHP 应用程序调用中提供用户名和密码来允许例外。这很简单,这里是 file_get_contents 函数的示例: http:// /www.electrictoolbox.com/php-file-get-contents-sending-username-password/。
您应该将类似的内容添加到您的 .htaccess 并删除其他限制:
以下是来自 apache 文档的更多信息: http://httpd.apache.org/docs/2.0/howto/auth.html
You might try using HTTP basic authentication to protect your files, but allow exceptions by providing a username and password in your PHP applications call. It's very simple, here is example for file_get_contents function: http://www.electrictoolbox.com/php-file-get-contents-sending-username-password/.
You should add something like this to your .htaccess and remove other restrictions:
Here is more info on this from apache docs: http://httpd.apache.org/docs/2.0/howto/auth.html