• Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Coolest Guides on the Planet

coolest guides on the planet

Come for the software, stay for the community

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Sort out your Canonical URLs in Drupal – Force http://www

August 4, 2011 3 Comments

canonical-url-drupal-www

canonical-url-drupal-www

Avoid any content duplication and ensure Google opts for a particular version of your site when indexing – fix up your redirects to choose either http://yourdomain.com or http://www.yourdomain.com by putting in a 301 redirect.

There is a possibility that failing to this may create duplicate content and be penalised by the Googler

You can get plugins for Drupal 7 to do this but earlier versions have limited modules, “nodewords” was being used for Drupal 6 but is now abandoned so best off to fix in the .htaccess file.

To force the use of http://www.yourdomain.com on your website instead of http://yourdomain.com you need to edit the .htaccess file in the web root directory.

The rules already exist – they just need to be uncommented out in the .htaccess file of the default Drupal install, have your domain applied to the example below.

Or just use:

RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Or edit the original component of the htaccess where appropiate, as shipped with Drupal 6

RewriteEngine on
# If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

 

You can also use Global Redirect and Meta Tags modules in Drupal 7 which sort out the canonical links via plugins.

Cats: Drupal, SEO, Tech Tags: drupal, Google, redirect, SEO, url

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Copyright © 2022· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2022 · gee on Genesis Framework · WordPress · Log in