的RewriteCond%{REQUEST_URI}:如何停止,如果REQUEST_URI含有P =约或P =接触?RewriteCond、REQUEST_URI

2023-09-02 20:34:32 作者:那时年少。

我试图创建.htaccess文件重写条件检查,如果网址包含设置和参数p =约或P =接触的参数p。 在情况下,如果P =约或P =联系,重写规则即低于不应该berformed。 任何人可以帮助我的RewriteCond?

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.

推荐答案

下的RewriteCond将匹配如果查询字符串没有一个 P 参数,值为关于我们联系人即下面的规则将不会执行,如果有AP = 关于我们联系人

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]