htaccess 与受密码保护的目录
我必须向我正在处理的站点添加密码保护区(使用 .htpasswd 文件)。问题是它所指向的整个目录结构并不存在,而是通过 mod_rewrite 创建的。
它仍然有效吗?或者该目录实际上必须存在于服务器上吗?
澄清: 虽然我可能需要密码保护目录: http://sitename/category/protected/
mod_rewrite 将其转换为: index.php?category=category&directory=protected
因此实际目录不存在。还可以保护吗?
I have to add a password protected zone to a site I am working on (using the .htpasswd file). The thing is the whole directory structure it's being pointed at doesn't exist and is created through mod_rewrite.
Will it still work, or does the directory actually have to physically exist on the server?
Clarification:
While I may need to password protect the directory:
http://sitename/category/protected/
mod_rewrite translates this to:
index.php?category=category&directory=protected
So the actual directory does not exist. Is it still protectable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将访问规则添加到目录或位置标记中的 apache 配置文件(httpd.conf 或类似文件),而不是将其添加到 .htaccess 文件中。
You can add the access rules to the apache config file (httpd.conf or similar) in a Directory or Location tag instead of adding it in the .htaccess file.
您的重写规则最终将指向系统上目录中的某些文件(除非它们将用户重定向到某个外部位置)。身份验证设置应位于将访问的基础目录上。
Your rewrite rules will ultimately point to some files in a directory on your system (unless they redirect users to some external location). The authentication setup should be on the underlying directory that will be accessed.