• 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!

Discuss

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
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • Apple confirms that its Maps app will begin showing ads to users "this summer"
  • Apple will talk iOS 27, macOS 27, and more at WWDC 2026 on June 8
  • Despite hardware limits, Parallels supports running Windows on MacBook Neo
  • Apple can delist apps "with or without cause," judge says in loss for Musi app
  • Apple’s AirPods Max 2 bring H2 chip, boosted ANC in April for $549

RSS mac surfer

  • Apple Updates App Store Connect Analytics Platform
  • macOS Tahoe 26.4 Update Released
  • watchOS 26.4 Update Released
  • tvOS 26.4 Update Released
  • visionOS 26.4 Update Released

Donate

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

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