重定向/ htaccess规则杀死查询字符串以使用wordpress超级缓存

Quite surprised I could not find the answer to this so posting for others as well as getting some help please.

I have a really busy and complicated wordpress site. It uses supercache heavily. Recently I have realised that slow page speed is down to users coming to pages that bypass Supercache, and this is because the site uses lots of referrers who come via query string type URLs.

www.site.co.uk/page/page/?utm_source=newsletter&utm_medium=email&utm_campaign=osale_3&cid=randomstringofnonsense

As the last bit is a 20 string random string the site generates this Url from scratch and adds to the cache list. Ideally I would like them just to be to directed to the proper page and use the same cache as normal folks. In other words kill off the query string and use the cached original:

www.site.co.uk/page/page/

This is what I have so far, but cannot get it to redirect or obey.

RewriteCond %{QUERY_STRING} ^utm_source=\*+$
RewriteRule ^$ /? [R,L]

Aiming to see if this significantly increases server speed and if so with revert to javascript to get any values back from the query string. Ideally the URL will not change but the user would be served cached version.

Help please.

Thanks in advance, Sam

I think that @anubhava has cleaned up the easy job for us ;-):

RewriteEngine On
RewriteCond %{QUERY_STRING} ^utm_source=
RewriteRule ^(.*)$ /$1? [R,L]

This will do:

  1. www.site.co.uk/page/page/?utm_source=newsletter&utm_medium=email&utm_campaign=osale_3&cid=randomstringofnonsense => www.site.co.uk/page/page/
  2. www.site.co.uk/page/page?utm_source=newsletter&utm_medium=email&utm_campaign=osale_3&cid=randomstringofnonsense => www.site.co.uk/page/page
  3. www.site.co.uk/?utm_source=newsletter&utm_medium=email&utm_campaign=osale_3&cid=randomstringofnonsense => www.site.co.uk/

Etc.