Skip to main content

If your Joomla site is accessible both with AND without a www-prefix you could have an issue with duplicate URL's. Google could see both versions of your pages as multiple instances of the same content and penalize your site for it. Make sure you choose one of those and make sure the other one is not accessible at all. Which one you choose does not matter to Google, but if Google does not care, why bother to type the www every time? Unless there are specific reasons, choose the non-www version. By the way, there are more situations where URL prefixes cause duplicate content issues (http / https, lowercase, uppercase, etcetera), but the www issue is the most frequent issue.

After you made your choice for www or non-www, configure your site to be accessible through only the chosen version, and set up a redirect from the non-preferred version to the preferred one. If you already have a SEF extension on your site, it may have an option to do so. If not, it is very easy to set up the redirect in your .htaccess file. Using .htaccess is the preferred option anyhow, as it is the fastest. Here is the code for our two scenarios:

Enforce non-www redirect

RewriteEngine On
RewriteCond %{HTTP_HOST}
RewriteRule (.*)$1 [R=301,L]

Enforce www redirect

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

After the change, always check if the redirect works as desired, or even if the site still works. A minimal typo could already result in a blank page or server error (500 code)... If this happens, just undo your change, or restore the .htaccess version distributed with new Joomla installs. By the way, if you use Akeeba's AdminTools, you can configure the redirect within the .htaccess maker as shown in this screenshot:

www htaccess joomla

SSL versions of your site

Note that when you install an SSL certificate, you could have the same issue as well: http:// and https:// also create duplicate versions of your pages. Also here, enforce the preferred version (obviously, use the https:// version). You can do so in Joomla's Global Configuration settings,  Server tab. Also, register both the http and the https versions of your site in Search Console then. 

Advanced tweaking

A while ago I had issues with one of my sites, where for some pages the IP-address version of the site was indexed by Google: a clear duplicate content issue Most sites don't suffer from this problem (so only apply this fix if you spot issues!), but in this case I needed to solve it. I redirected all traffic directed over the IP-address of my server to the actual site, using a variation of the code above, where XXX.XXX.XXX.XXX needs to be replaced by the IP-address:

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

Sometimes you can even have other variations of your domain. Just make sure to monitor your SEO status to keep track of this. You can useSEO Powersuite's Website Auditor for this.

Ad - SiteGround Web Hosting - Crafted for easy site management. Amazing Speed; Powerful Tools; Top-rated support. Learn more.