gpt4 book ai didi

apache - 使用基本身份验证 (htaccess) 限制对特定 URL 的访问

转载 作者:行者123 更新时间:2023-12-04 12:56:13 24 4
gpt4 key购买 nike

我需要限制对特定 URL 的访问,例如http://mydomain.com/this/is/the/url在我的网络服务器上通过 Apache 使用基本身份验证。任何其他 URL 都应该是可公开访问的。我已经看到您可以使用以下方法向文件添加特定规则:

<Files "mypage.html">
Require valid-user
</Files>

我的问题是所有请求都使用 mod-rewrite 路由到 Controller ,所以我认为我不能根据文件限制访问。任何想法都会最有帮助!

最佳答案

在 .htacess 文件中,您应该输入:

AuthType Basic
AuthName "Need to login"
AuthUserFile .htpasswd file location ;
Require user USER

//AuthName is login prompt message
//AuthUserFile is physical .htpasswd file location i.e.
C:/xampp/htdocs/basic/.htpasswd
//Require user is for a specific user i.e. the username you want to
authenticate

要生成 .htpasswd 文件,您可以使用:
- http://www.htaccesstools.com/htpasswd-generator/

关于apache - 使用基本身份验证 (htaccess) 限制对特定 URL 的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5404470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com