.htaccess 拒绝访问文件夹

发布于 2024-10-03 09:20:34 字数 279 浏览 0 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

定格我的天空 2024-10-10 09:20:34

我可能是错的,去 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 and allow from <YOUR IP>

贵在坚持 2024-10-10 09:20:34

您可以尝试使用 HTTP 基本身份验证来保护您的文件,但通过在 PHP 应用程序调用中提供用户名和密码来允许例外。这很简单,这里是 file_get_contents 函数的示例: http:// /www.electrictoolbox.com/php-file-get-contents-sending-username-password/

您应该将类​​似的内容添加到您的 .htaccess 并删除其他限制:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user wizztjh

以下是来自 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:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user wizztjh

Here is more info on this from apache docs: http://httpd.apache.org/docs/2.0/howto/auth.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文