1

I am getting duplicate content issues because both www and non-www are being loaded.

My htaccess has the standard force https as all my other sites but it isn't working.

# START Force https
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{HTTP_HOST} ^(www\.)?geniusesforhire\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.geniusesforhire.com/$1 [R=301,L]
# END Force https

Could anything in Craft be causing this or is anything in Craft able to fix this?

1

2 options to avoid duplicate content:

  • add a canonical tag to your HTML
  • redirect non-www to www or vice versa
1

Your Apache redirect rule is only redirecting http -> https.

You also want a rule to redirect non-www hits to the www version.

Something like:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https://www.geniusesforhire.com/$1 [R=301,L]

As Matthias mentions in his answer, I'd also put a link tag somewhere in the head of your Twig template. Assuming craft's entry variable is available:

{% if entry is defined %}<link rel="canonical" href="{{ entry.url }}">{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.