如果没有其他规则匹配,则 Mod_rewrite 规则

发布于 2024-10-04 22:29:40 字数 61 浏览 0 评论 0原文

有没有办法执行一种“捕获所有”规则,只有在我的 .htaccess 文件中没有匹配其他规则时才会匹配该规则?

Is there a way to do a sort of "catch all" rule that will only be matched if no other rules have been matched in my .htaccess file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹短裙飘 2024-10-11 22:29:40

将此规则作为最后一条规则以捕获无法映射到现有文件的任何请求:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ catch-all.foo

Put this rule as last rule to catch any request that could not be mapped onto an existing file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ catch-all.foo
如梦 2024-10-11 22:29:40

如果您将规则放在底部,而其他规则带有 [L],则它将被视为包罗万象。

if you put your rule at the bottom, and have your other rules with a [L], it'll be considered the catch-all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文