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

编程入门 行业动态 更新时间:2024-10-17 17:16:09
本文介绍了仅允许某些文件通过.htaccess查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

i have almost 20 pages on server, but i want only a file named abc.php, which users can watch. i want if user forcefully open the other files like //example/some.php .htaccess shows 403 error.

<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>

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

this is the way i am currently using, but i think there can be more elegant solutions.

推荐答案

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

This .htaccess-file will only allow users to open index.php. Attempts to access any other files will result in a 403-error.

Order deny,allow Deny from all <Files "index.php"> Allow from all </Files>

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

If you also want to use authentication for some of the files, you may simply add the content from your current file at the end of my example.

更多推荐

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

本文发布于:2023-11-01 12:58:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549398.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!