How to to force the use of www.example.com instead of example.com?

Permalink
I wish to force the use ofhttp://www.example.com instead of example.com.
I think I have to modify the .htaccess file but I don´t know how.
Can anyone help me?
Thanks.

-----
Answer:
I found it here
http://www.concrete5.org/community/forums/customizing_c5/redirect-n...

frankysev
 
apc123 replied on at Permalink Reply
apc123
Hi,

Use this in your htaccess file.
This will replaces the "enable pretty URLs" code that Concrete5 adds.
Swap out YourHostName.com for your sites URL and you should be good to go.

Cheers,
Anthony


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^YourHostName.com
RewriteRule (.*)http://www.YourHostName.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>
cherrycake replied on at Permalink Best Answer Reply
cherrycake
The only thing you need to do is to modify your site.php file under /config.

Add this value to /config/site.php:

define('BASE_URL', 'http://www.example.com');

That should automatically ensure that the url is displayed/rewritten ashttp://www.example.com. I use this on pretty much every site i build for this very reason.