Redirecting non-www and www in Joomla!

3 Minute Read

Summary (tl;dr)

Your site actually has two domains: htttp://www.yourdomain.com and http://yourdomain.com. One has the www and the other is considered non-www. Having both active can hurt search engine optimization and it is generally considered good practice to choose one and redirect requests for the other. Adding a redirect for your Joomla! site involves a little .htaccess editing.

Redirecting non-www and www in Joomla!

Deciding between non-www and www can be potentially crucial for the search engine rankings of your Joomla! site. Having both versions active can cause duplicate content, cookie issues, or session problems. It's like having two entrances to your home in the front. You end up having some people use the non-www door, while some people are knocking on the www door.

The best SEO practice for your site is going to be choosing either the non-www or www door and redirecting all of your traffic to it. This ensures that you won't have multiple entrances and everything will be funneled through the same entrance.

Editing Your .htaccess

The first thing you need is access to your .htaccess file, located in the root of your Joomla! installation. This file controls a number of things including redirects.

Find the line that has:

RewriteEngine on

Below it you will either add the redirect non-www to www code:

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

...or the redirect www to non-www code:

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

Save the changes and your site should now reflect the redirect you chose.

Need More Help?

If you are having trouble redirecting your site to www or non-www, The Web Mechanics can help! Our Joomla! Support and Website Support packages cover changes just like this as well as routine updates, daily backups, 24/7 support, and hack protection.