---
title: "htaccess redirect non-www to www version"
date: "2013-03-25"
path: "/119-htaccess-redirect-non-www-to-www-version.html"
section: "/ramblings"
aliases:
  - "/119"
  - "/119-htaccess-redirect-non-www-to-www-version"
  - "/119.html"
  - "/ramblings/119-htaccess-redirect-non-www-to-www-version.html"
---

This is pretty simple; in Joomla place the following code after the block where rewrites get turned on in the .htaccess file (`nano .htaccess`):

```
RewriteEngine On

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

On saving the file you will now have a site that only works from one sub-domain i.e. the correct main "www" one.
