apache - 不要将重写规则应用于特定的文件扩展名
问题描述
我有一个 htaccess 可以在特定情况下重写一些 url。
RewriteEngine On
RewriteRule \.php$ - [L,NC]
RewriteRule ^(?:favicon\.ico|(?:index|custom500|custom404)\.html)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?source=$0 [L,QSA]
在里面我有一个规则,防止 index.html、custom404.html、custom500.php 和 favicon.ico 被包含在重写中。现在我正在尝试为任何以 pdf 或 jpg 扩展名结尾的文件添加相同的逻辑。所以我尝试将pdf扩展名添加到排除列表
RewriteRule ^(?:favicon\.ico|(?:index|custom500|custom404)\.html|?:\*\.pdf)$ - [L,NC]
但是 apache 无论如何都会将此文件作为index.php?source=myfile.pdf
如何将 .pdf 和 .jpg 正确添加到此列表中?
解决方案
推荐阅读
- javascript - Difference between v-on:click="..." and using onclick="..." in Vue.js
- c# - 使 JIT 编译器在调试模式下优化某些类
- css - Bootstrap 4 - 当我打开模式时背景移动
- java - LMDB Java 检索具有相同键的所有值
- php - 将数据添加到 wp_users 表中的自定义字段中
- javascript - 有没有比调用多个 ajax 查询更快的方法来比较列表中的项目?
- python - 将文本文件中的数据插入 csv 列
- angular - highchart 范围选择器在 highchartjs、highchart-ng 升级后未显示
- c# - c#-无法使用 openpop.net 检索电子邮件
- python - 我的脚本运行良好,但由于我已经转移到另一台笔记本电脑