RewriteCond %{REQUEST_URI} :如果 REQUEST_URI 包含 ?p=about 或 ?p=contact,如何停止

发布于 2024-12-27 20:25:44 字数 244 浏览 2 评论 0原文

我正在尝试在 .htaccess 文件中创建重写条件,以检查 url 是否包含已设置的参数 p 以及参数 p=about 或 p=contact。 如果 ?p=about 或 ?p=contact,则不应执行下面的 RewriteRule。 有人可以帮助我使用 RewriteCond 吗?

RewriteCond %{REQUEST_URI} (?p=about_us|?p=contact)

不起作用。

I'm trying to create a rewrite condition in .htaccess file to check if url contains a parameter p that is set and parameter p=about or p=contact.
In case, if ?p=about or ?p=contact, the RewriteRule that is below should NOT be berformed.
Could anybody help me with RewriteCond?

RewriteCond %{REQUEST_URI} (?p=about_us|?p=contact)

does NOT work.

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

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

发布评论

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

评论(1

ˉ厌 2025-01-03 20:25:44

如果查询字符串没有值为 about uscontactp 参数,则下面的 RewriteCond 将匹配,即以下规则不会匹配如果有 ap= 关于我们contact 则执行

RewriteCond %{QUERY_STRING} !(^|&)p=(about_us|contact)(&|$) [NC]

The RewriteCond below will match if the query string does not have a p param with a value of about us or contact i.e the following rule will not execute if it has a p= about us or contact

RewriteCond %{QUERY_STRING} !(^|&)p=(about_us|contact)(&|$) [NC]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文