Mod rewrite 剥离查询字符串后重写条件不起作用

Mod rewrite 剥离查询字符串后重写条件不起作用,mod-rewrite,url-rewriting,iis-6,iirf,Mod Rewrite,Url Rewriting,Iis 6,Iirf,我正在Windows 2003服务器上的IIS6上使用iirf。我们有以下代码来显示干净的URL并删除任何查询字符串: RewriteRule ^/(.+)\?(.+)&(.+)\.(htm)$ /$1 RewriteRule ^/(.+)\?(.+)$ http://betatest.bracknell-forest.gov.uk/$1 [R=301] # Redirect to ASP if it exists. # e.g. example.com/foo

我正在Windows 2003服务器上的IIS6上使用iirf。我们有以下代码来显示干净的URL并删除任何查询字符串:

RewriteRule ^/(.+)\?(.+)&(.+)\.(htm)$  /$1    
RewriteRule ^/(.+)\?(.+)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# Redirect to ASP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.asp

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA] 
RedirectRule ^/(.+)\.(asp)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# Any bare URL will get rewritten to a URL with .htm appended
RewriteRule ^/([\w]+)$ /$1.htm [I,L]
RedirectRule ^/(.+)\.(htm)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]
问题是,既然我添加了 重写规则^/(.+)\?(.+)&(.+)(htm)$/$1
重写规则^/(.+)\?(.+)$$1[R=301]

所有查询字符串参数在我们实际需要它们的地方都被删除(对不起,URL在外部不可用): betatest.bracknell forest.gov.uk/news.asp?page=2 事实上,我们想要去除参数的唯一查询字符串条件是它是否包含Facebook参数fb_action_ids=52352315213,例如。 betatest.bracknell forest.gov.uk/help?fb_action_id=372043216205703&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582 我试过使用:

RewriteCond %{QUERY_STRING} ^ fb_action_ids=(.)$ [I]

在第一对规则之前,但它似乎没有起到任何作用。

刚刚设法解决了它,男孩,这感觉就像是我肩上的负担:

#key thing I have changed is to specify the query string parameters fb_action_ids and fb_source
RewriteRule ^/(https?)://([^/]+)(/([^\?]+(\?(.*))?)?)?  /$1
RewriteRule ^/(.+)\?(fb_action_ids=(.*)|fb_source=(.*))$  http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# e.g. example.com/foo will display the contents of example.com/foo.asp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA] 
RedirectRule ^/(.+)\.(asp)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# Any bare URL will get rewritten to a URL with .htm appended
RewriteRule ^/([\w]+)$ /$1.htm [I,L]
RedirectRule ^/(.+)\.(htm)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

刚设法解决了这个问题,男孩,我觉得这就像是我肩上的负担:

#key thing I have changed is to specify the query string parameters fb_action_ids and fb_source
RewriteRule ^/(https?)://([^/]+)(/([^\?]+(\?(.*))?)?)?  /$1
RewriteRule ^/(.+)\?(fb_action_ids=(.*)|fb_source=(.*))$  http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# e.g. example.com/foo will display the contents of example.com/foo.asp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA] 
RedirectRule ^/(.+)\.(asp)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# Any bare URL will get rewritten to a URL with .htm appended
RewriteRule ^/([\w]+)$ /$1.htm [I,L]
RedirectRule ^/(.+)\.(htm)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]