regex - FilesMatch 指定路径
问题描述
<FilesMatch "\.html$">
如何在基目录中仅指定.html 文件?
我想
https://www.example.com/page.html
但不是 https://www.example.com/directory/page.html
解决方案
由于规则在.htaccess
根目录中,从下面的讨论中可以清楚地看出,试试这个
<FilesMatch "^\.(html|php)$">
<If "%{REQUEST_URI} =~ m#^/[^/]+\.(html|php)$#">
(your directives)
</If>
</FilesMatch>
请参阅https://httpd.apache.org/docs/2.4/sections.html#file-and-web、https://httpd.apache.org/docs/2.4/mod/core.html#if和https:// /httpd.apache.org/docs/2.4/expr.html。
推荐阅读
- python - 第一次附加后 append_entry() 不起作用。我正在将 Fieldlist 与 flask-wtf、jinja 和 Python 3.4 一起使用
- java - Java 部分解组
- c# - 为什么泛型的 Type.Name 属性以撇号和数字结尾?
- matlab - 在 MATLAB 的神经网络工具箱中使用 LM 算法进行训练
- ios - NavigationBarItem:Google 地图导航栏中的 BackButtonItem
- android - 在很长一段时间内的特定日期发出通知
- http - JW Player 无法在 https 上运行
- bash - 哪个触发了内部错误?
- php - 如何在 php 查询中使用 $_COOKIE?
- javascript - ES6 Promises 使用的浏览器特性是什么?