gpt4 book ai didi

apache - 仅允许某些文件通过 .htaccess 查看

转载 作者:行者123 更新时间:2023-12-04 00:19:26 25 4
gpt4 key购买 nike

我在服务器上有将近 20 页,但我只想要一个名为 abc.php 的文件,用户可以观看。我想如果用户强行打开其他文件,如//example.com/some.php .htaccess 显示 403 错误。

<Files ~ "^(?!(changepwd|login|register|remind|securitycode|registersuggest)\.php$).*(\.php)$">
AuthName "Reserved Area"
AuthType Basic
AuthUserFile path_to/.htpasswd
AuthGroupFile path_to/.htgroup
Order Deny,allow
Require group allowed_groups
</Files>

这是我目前使用的方式,但我认为可以有更优雅的解决方案。

最佳答案

.htaccess -file 将只允许用户打开 index.php .尝试访问任何其他文件将导致 403 错误。

Order deny,allow
Deny from all

<Files "index.php">
Allow from all
</Files>

如果您还想对某些文件使用身份验证,您只需在我的示例末尾添加当前文件中的内容即可。

关于apache - 仅允许某些文件通过 .htaccess 查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19617351/

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