How to fix Drupal’s Canonical errors

I’m writing this because if you are like me and experiencing issues with canonical errors on a new Drupal site, a killer SEO problem, much of what you will find on Google will reference two types of fixes, however the one you need probably won’t pop up.

I found this very annoying as SEO with Drupal is such a saturated topic. But it wasn’t until I was looking through the documentation for the module XML Sitemap that I found out what was causing the canonical error, my settings.php file.

To fix the canonical error of a Drupal site, make sure in your settings.php file that you uncomment the following line:

$base_url = ‘’; // NO trailing slash!

With a typical install of Drupal you’ll most likely find this file in var/www/html/sites/default/settings.php

So that’s what I had missed, but this alone is not the only thing you’ll have to do. You may have already done it, but next is editing your .htaccess file to uncomment the following lines (note: they are not next to each other, though if you have no .htaccess file you can just make a text file with this info)

Options +FollowSymLinks
RewriteEngine on
RewriteBase / //note: this is if your site runs from and not other wise use RewiteBase /drupal
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [R=301,NC,L]

This should typically fix things, but I went a step further and placed the following in my themes page.tpl section:

Likewise, if you are looking for the “essential” SEO modules, I’d advise you to read this great post on the subject of SEO for Drupal here.

You should also have an account with and under your Site Configuration select Settings and then tell Google that you prefer for your site instead of


1 Comment

  1. Murray Belflower

    Thanks for the facts about that. I wrote it off as yet another expense, but I’m going to look into it once again.

Leave Comment

Your email address will not be published. Required fields are marked *