What does your whole mod_rewrite configuration look like in order? I'm no pro with mod_rewrite, but what it looks like you need to do is, redirect old references to the new one first... So anything with ^ref=3.6 redirects to the new rule first, THEN redirect Testing-Instruments.html calls. If you do it the other way around, you will be converting the new calls to refs, then the refs to new calls, then it will infinite loop.
So something like this (this is just reusing your code in different order, don't know if it'll work):
RewriteCond %{QUERY_STRING} ^ref=3.6$
RewriteRule ^cgi-bin/ab_page\.pl$ http://www.domain(dot)co(dot)uk/Testing-Instruments.html? [R=301,L]
#Do this after
RewriteRule ^Testing-Instruments.html$ /cgi-bin/ab_page(dot)pl?ref=3.6
- RewriteCond %{QUERY_STRING} ^ref=3.6$
- RewriteRule ^cgi-bin/ab_page\.pl$ http://www.domain(dot)co(dot)uk/Testing-Instruments.html? [R=301,L]
- #Do this after
- RewriteRule ^Testing-Instruments.html$ /cgi-bin/ab_page(dot)pl?ref=3.6
Anyway, the variable you're looking for I think is %{REQUEST_URI}, so something like...
RewriteCond %{REQUEST_URI} ^(.*)ref=3.6(.*)$
RewriteRule ^cgi-bin/ab_page\.pl$ http://www.domain(dot)co(dot)uk/Testing-Instruments.html? [R=301,L]
- RewriteCond %{REQUEST_URI} ^(.*)ref=3.6(.*)$
- RewriteRule ^cgi-bin/ab_page\.pl$ http://www.domain(dot)co(dot)uk/Testing-Instruments.html? [R=301,L]
There's no place like 127.0.0.1, badass part is now it's ::1