# .htaccess redirect non-www to www

**URL:** <https://forum.kirupa.com/t/htaccess-redirect-non-www-to-www/223078>\
**Category:** programming\
**Created:** [April 19, 2007, 11:08am UTC](https://forum.kirupa.com/t/htaccess-redirect-non-www-to-www/223078 "2007-04-19T11:08:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duncanhall](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@duncanhall](https://forum.kirupa.com/u/duncanhall)\
**Post date:** [April 19, 2007, 11:08am UTC](https://forum.kirupa.com/t/htaccess-redirect-non-www-to-www/223078/1 "2007-04-19T11:08:49Z")

</div>

I’m using amfphp in a current project, which requires users to view “[www.theDomain.co.uk](http://www.theDomain.co.uk)” rather than simply “[theDomain.co.uk](http://theDomain.co.uk)”. To ensure all users get complete functionality, I am trying to reidrect all non-www pages to their www-prefixed counterpart.

This is how my .htaccess file currently looks:

```auto

###### Redirect / to www ######
RewriteCond %{HTTP_HOST} ^theDomain.co.uk
RewriteRule (.*) http://www.theDomain.co.uk/$1 [R=301,L]
RewriteRule ^$ index.php
#########################

```

If I type in “[http://theDomain.co.uk/dev](http://theDomain.co.uk/dev)” to view the development site, the redirect works and I am taken to “[http://www.theDomain.co.uk/dev](http://www.theDomain.co.uk/dev)”.

However, If I simply target "“[http://theDomain.co.uk](http://theDomain.co.uk)” the redirect appears to do nothing and the page remains at the non-www version.

Any ideas?
