Canonical Redirects

Here is some quick code to put into your .htaccess file. These kind of redirects are called “Canonical Redirects.”

Redirect non-www to www version

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Redirect www to non-www version

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [nocase]
RewriteRule ^(.*) http://example.com/$1 [last,redirect=301]

Pretty basic post but its pretty useful.

By: on Jul 16
Cateogry: Web
Tags: ,

Contact

We are ready to handle any of your web needs. Use the form below to contact us and we'll get back with you in a timely fashion.

If you would like to setup a meeting, we can come out to your place no matter where you are.

Name*

Email*

Message