I have a htaccess file which redirects
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.example.co.uk%{REQUEST_URI} [R=301,L]
This redirects everything to https://www.example.co.uk fine. But if i take the www. away so it's https://example.co.uk it opens that page without the www.
Has anybody encountered this and found a way around it so that everything redirects to the desired url? I'm only doing it as ahrefs and search console crawlers are seeing some of the things as duplicate content.
Thanks in advance for any feedback.