RewriteCond as written: If the requested domain is anything other than exactly "example.co.uk" (whoops! forgot to escape a \.there) ... then
RewriteRule as written: Redirect to http://example.co.uk keeping the rest of the URL unchanged.
It redirects www.example.com/pagename back to example.com when it should be example.com.pagename
Do you mean that no matter what file you request, you end up on the front page instead of on the page you asked for? There's got to be another rule making this happen. Your rule has the capture () and reuse $1 in the right places, so you have to look elsewhere.
Please say that ".pagename" is a typo for "/pagename" and ".com" is a typo for ".co.uk". Otherwise none of it makes sense.
The rule you quoted should come at the very end of all your redirects, after the more specific redirects. (Does not apply if, ahem, you don't have any other redirects.) Putting it earlier probably won't cause errors, but it may lead to a single request being redirected twice. And one of those later redirects is the one causing the problem.
If it's just www to non-www (without the complexities of pagename), most domain registrars allow you to set up A records for example.com, www.example.com and *.example.com. Or you can do a URL redirect at the registrar level as well.
You can also use ServerAlias to do that: ServerName example.com ServerAlias *.example.com