.htaccess RewriteCond 问题

发布于 2024-10-06 23:28:13 字数 311 浏览 0 评论 0原文

我的 .htaccess 中有这个:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/includes
RewriteCond %{REQUEST_URI} !/images
RewriteRule (.*) index.php

它通过 index.php 重定向所有页面,但 include 和 images 文件夹除外。这是使用异常的正确方法吗?还有一种方法可以仅在一个 RewriteCond 规则上使用异常,而不是在单独的行上使用每个异常?

I have this in my .htaccess:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/includes
RewriteCond %{REQUEST_URI} !/images
RewriteRule (.*) index.php

It redirects all pages through index.php with the exception of the includes and images folder. Is this the correct way to use the exceptions? Also is there a way to use the exceptions on just one RewriteCond rule instead of each on a seperate line?

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

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

发布评论

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

评论(1

相守太难 2024-10-13 23:28:13

对于例外情况来说这很好,尽管您可以在 ! 之间添加 ^ 。和 / 使其显示“开始于”。至于组合它们,您可以执行以下操作:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(includes|images)
RewriteRule (.*) index.php

That is fine for the exceptions, though you could add a ^ inbetween the ! and / to make it says "starts with". As for combining them, you can do the following:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(includes|images)
RewriteRule (.*) index.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文