Variable Visions

Articles Apache Canonical-or-301-Redirect

tutorials - Apache and Web-Development.

Canonical or 301 Redirect?

Published Mon. Oct. 29, 2012

Which to use?

Now, to let search engines know which url is the "preferred version", the CANONICAL href can be defined in this link tag to be placed within the head tag. (of pages creating ugly query string urls)

<link rel="canonical" href="" />

While this rewrite rule rewrites non-www traffic to www, the above CANONICAL link tag tells search engines which is the "preferred version" ... to avoid duplicate content.(only works in one domain root)

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [R=301,NC]

 CANONICAL tag is fairly new, and some of us have been using url rewriting for a while now.

I've added it to the head tag of my header template file, but I'm not sure I need research tells me it is needed to be placed in pages that create "ugly" urls....i guess I'm confused if I need to use the CANONIAL tag if I ALREADY use rewrite rules to rewrite ?title=article-title to /articles/article-title to keep the url "pretty"...IS THIS CONSIDERED DUPLICATE CONTENT IF I NEVER USE, DISTRIBUTE, INCLUDE IN ANY MENUS, OR INCLUDE IN THE SITE MAP THE UGLY URLs ?

Read my article on mod_rewrite

RewriteRule ^articles/(.*) /index.php?title=$1


Use a 301 Redirect for older pages, for "ugly" non-SEO-friendly URLs, when someone types or links and forgets the www, or if you need to redirect to another domain.

Use a Rel=“Canonical” tag when your URLs have sessions ids, query strings that can not be rewritten.





Read this article from


"The bottom line is that the canonical tag should only be used when necessary. Applying best practices in URL creation and linking and using a 301 redirect should be used whenever possible, but in those instances when duplicate content can’t be avoided, a rel=“canonical” tag is a fantastic way to assure that search engines accurately index your site."

Tag(s): Canonical, 301 Redirect?