使用基本身份验证(htaccess的)限制访问特定的网址身份验证、基本、网址、htaccess

2023-09-02 00:49:51 作者:不舍流年

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

I need to restrict access to a particular URL, e.g. http://mydomain.com/this/is/the/url on my webserver using Basic Authentication through Apache. Any other URL should be openly accessible. I have seen that you can add specific rules to files using:

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

我的问题是,所有的请求路由到使用mod-rewrite控制器,所以我不认为基于文件,我可以限制访问。任何想法将是最有帮助的!

My problem is that all requests are routed to controllers using mod-rewrite and so I don't think that I can restrict access based on the file. Any ideas would be most helpful!

推荐答案

您可以通过将一个单独的的.htaccess 在该目录中保护整个目录。本教程说明它比我更可以:

You can protect the entire directory by placing a separate .htaccess in that directory. This tutorial explains it better than I could:

http://www.addedbytes.com/lab /密码保护 - 一个目录与 - htaccess的/