Answers.Body: <p>2 options to avoid duplicate content:</p>
  <ul>
  <li>add a canonical tag to your HTML</li>
  <li>redirect non-www to www or vice versa</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-30T05:55:45.030Z
Answers.LastActivityDate: 2020-08-30T05:55:45.030Z
Answers.UserDisplayName: Matthias Redl-Mann
Answers.Body: <p>Your Apache redirect rule is only redirecting http -&gt; https.</p>
  <p>You also want a rule to redirect non-www hits to the www version.</p>
  <p>Something like:</p>
  <pre><code>RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{SERVER_PORT} 443
  RewriteRule ^(.*)$ https://www.geniusesforhire.com/$1 [R=301,L]
  </code></pre>
  <p>As <a href="https://craftcms.stackexchange.com/a/36111/1016">Matthias</a> mentions in his answer, I'd also put a <code>link</code> tag somewhere in the head of your Twig template. Assuming craft's <code>entry</code> variable is available:</p>
  <pre><code>{% if entry is defined %}&lt;link rel=&quot;canonical&quot; href=&quot;{{ entry.url }}&quot;&gt;{% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-31T15:20:33.420Z
Answers.LastActivityDate: 2020-08-31T15:20:33.420Z
Answers.UserDisplayName: RitterKnight
Body: <p>I am getting duplicate content issues because both www and non-www are being loaded.</p>
  <p>My htaccess has the standard force https as all my other sites but it isn't working.</p>
  <pre><code># 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
  </code></pre>
  <p>Could anything in Craft be causing this or is anything in Craft able to fix this?</p>
  
Tags: <htaccess>
Title: Duplicate content from www and non-www
ThreadText: # Duplicate content from www and non-www
  
  (Asked by: username_0 on 2020-08-28)
  
  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?
  
  **Tags:** htaccess
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-08-30. Score: 1
  
  2 options to avoid duplicate content:
  
  * add a canonical tag to your HTML
  * redirect non-www to www or vice versa
  
  
  ---
  
  ### Answer by username_2 on 2020-08-31. Score: 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 [username_1](https://craftcms.stackexchange.com/a/36111/1016) 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 %}
  
  ```
  
  
  ---
  
  