regex - htaccess 允许带有正则表达式的文件
问题描述
我正在使用 htaccess 拒绝访问我的 php 文件。不过我需要从外部调用其中一些,例如 index.php
我想出了
<Files a_string_a.php>
Order Allow,Deny
Allow from all
</Files>
按预期工作,我可以使用该文件。但我有几个文件。我想避免为每个文件写一个这样的块。是否有机会解释 htaccess 它将允许访问所有匹配的文件
..._string_.....PHP? (containing a unique string no matter what else is in the filename)
我很确定有一个 RegExpress,但我有点迷茫,没有起诉如何将它集成到 htacess 中 - 谢谢你的提示。
解决方案
也许是这样的:
<FilesMatch "(index|foo|bar)\.php$">
Order Allow,Deny
Allow from all
</FilesMatch>
并使用 | 添加任何文件基名 (正则表达式或)。
推荐阅读
- css - 使用 TamperMonkey UserScript 修改网页框架大小
- android - kotlin 中父类的数据绑定
- nim-lang - 为什么 Nim 宏中有奇怪的运算符优先级?
- pine-script - 如何从 pine-script 中的最后一个枢轴返回样本量的值?
- android - 使用 Flutter 在应用程序中实现的秒表(具有计时器功能)在应用程序进入后台模式时暂停
- android-studio - 如何在kotlin中不断检查底板的状态?
- reactjs - jwt令牌过期时如何自动注销反应
- powershell - PowerShell 新手,试图找到可以为 IP 列表提供此输出的内容
- css - 如何减少 svg 图标的重量/厚度?
- android - 首选项DataStore从常用方法中读取数据