.htaccess 检查查询字符串中是否存在键-htaccess

.htaccess 检查查询字符串中是否存在键-htaccess,.htaccess,.htaccess,我的url具有如下查询字符串: ?v=11&icid=someid&near=far OR ?icid=some&v=11&near=far OR ?icid=some&near=far&v=11 OR ?v=11 OR There may be more but "v" exists 在htaccess中,我如何执行以下操作 如果键“v”存在 和 该值不是[1-11] 重定向到我的站点 到目前为止,我得到了以下信息: 示例url:?(上述QS之

我的url具有如下查询字符串:

?v=11&icid=someid&near=far
OR
?icid=some&v=11&near=far
OR
?icid=some&near=far&v=11
OR
?v=11
OR
There may be more but "v" exists
在htaccess中,我如何执行以下操作

如果键“v”存在 和 该值不是[1-11] 重定向到我的站点

到目前为止,我得到了以下信息:

示例url:?(上述QS之一)

重写cond%{QUERY_STRING}v
重写cond%{QUERY_STRING}v=([^1-11]+)
重写规则([1000-9999]+)/([^/]+)/([^/]+)/([^/]+)/?([0-99]+)?$http://%{http_HOST}/?[R,L]

非常感谢您在这方面的任何帮助。

谢谢,
L

以下是我的尝试:

#grab the v parameter, allowing it to appear anywhere within the query string,
#without matching part of another parameter name such as "gov"
RewriteCond %{QUERY_STRING} (?:^|&)v=([^&]*)(?:$|&)

#check if it's NOT set to a digit between 1-11
RewriteCond %1 !^(?:[1-9]|1[01]?)$

#Begin matching anywhere within the requested URL, since there's no leading caret.
#If this should match the beginning, and not somewhere within the middle,
#then add a leading caret.
#The logic is as follows:
#Check if we have a number between 1000 and 9999 followed by a slash;
#then three slash delimited chunks with slashes in between;
#then an optional chunk which, if matched, must begin with a slash, then 
#a number between 0 and 99 (including a leading zero);
#followed by an optional tailing slash;
#followed by the end of the string.
RewriteRule ([1-9]\d{3})/([^/]+)/([^/]+)/([^/]+)(?:/(\d\d?))?/?$ http://%{HTTP_HOST}/? [R,L]

#more rules can go here if we didn't redirect

[^1-11]
肯定是错的。
#grab the v parameter, allowing it to appear anywhere within the query string,
#without matching part of another parameter name such as "gov"
RewriteCond %{QUERY_STRING} (?:^|&)v=([^&]*)(?:$|&)

#check if it's NOT set to a digit between 1-11
RewriteCond %1 !^(?:[1-9]|1[01]?)$

#Begin matching anywhere within the requested URL, since there's no leading caret.
#If this should match the beginning, and not somewhere within the middle,
#then add a leading caret.
#The logic is as follows:
#Check if we have a number between 1000 and 9999 followed by a slash;
#then three slash delimited chunks with slashes in between;
#then an optional chunk which, if matched, must begin with a slash, then 
#a number between 0 and 99 (including a leading zero);
#followed by an optional tailing slash;
#followed by the end of the string.
RewriteRule ([1-9]\d{3})/([^/]+)/([^/]+)/([^/]+)(?:/(\d\d?))?/?$ http://%{HTTP_HOST}/? [R,L]

#more rules can go here if we didn't redirect