SEO and CDN
So you decided to start using a CDN provider for your website. A good idea! But a lot of CDN providers use a custom URL that you should CNAME when everything is set up properly.
For instance Fastly and Cloudfront two big CDN providers.
When I want to add this website to Fastly they will give me the URL: www.triquanta.nl.global.prod.fastly.net
For Cloudfront it will be something like: d67something714.cloudfront.net
Once you CNAME'd these people will most likely not see these. But it can happen that these domains are going to be indexed by search engines.
And there you have it.... Duplicate content.
This means that your CDN provider is concurring the actual main domain. You don't want this, because it is a bad thing for your Search Engine Optimization (SEO)
To prevent this use the Canonical meta tag for all of your content pages. ( see https://support.google.com/webmasters/answer/139066?hl=en&rd=1 for more info)
In Drupal this can be done using the metatag module https://www.drupal.org/project/metatag this module can add the canonical and a lot of other desired meta-tags (see https://groups.drupal.org/node/229413 for the full list).
Now your content is okay but what about your files (images, pdf, word, etc).....
Since 2011 Google (and the rest followed Google) also support the canonical when it is used in the response headers. The next step is to add the header to the files. This can be done on your own server.
Apache .htaccess example with mod rewite and mod headers enabled.
- <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|webp|html)(\.gz)?(\?.*)?$">
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{HTTPS} !=on
- RewriteRule .* - [E=CANONICAL:http://www.triquanta.nl%{REQUEST_URI},NE]
- RewriteCond %{HTTPS} =on
- RewriteRule .* - [E=CANONICAL:https://www.triquanta.nl%{REQUEST_URI},NE]
- </IfModule>
- <IfModule mod_headers.c>
- Header set Link "<%{CANONICAL}e>; rel=\"canonical\""
- </IfModule>
- </FilesMatch>
Ngnix example.
- location ~ \.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|webp|html)(\.gz)?(\?.*)?$ {
- add_header Link "<$scheme://www.triquanta.nl$request_uri>; rel=\"canonical\"";
- }
When a file is being accessed using the CDN URL it will add the proper Canonical headers, and you will not have any duplicate content issues.