0

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.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Possible duplicate of [Redirect non-www to www in .htaccess](https://stackoverflow.com/questions/12050590/redirect-non-www-to-www-in-htaccess) – Hackerman Feb 13 '18 at 12:37
  • please , paste all code inside htaccess file , your code should catch a request without wwww – Mohammed Elhag Feb 13 '18 at 15:27
  • I can't paste it all as it's too long for the comment section. I'm using the boilerplate template with the only changes being what i pasted in original query above. https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess?ts=2 – Osian Jones Feb 14 '18 at 13:37

0 Answers0