Forum Moderators: phranque

Message Too Old, No Replies

how do I force the www in my URL?

         

Phrasebase

10:07 pm on Aug 6, 2007 (gmt 0)

10+ Year Member



I don't want visitors to ever goto http://example.com , I want to force them to http://www.example.com.

Does anyone know how I can do this?
Thanks

[edited by: encyclo at 4:40 pm (utc) on Aug. 7, 2007]
[edit reason] switched to example.com [/edit]

callivert

11:14 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You have to edit a file in your main public folder called .htaccess (yes it's a weird looking file name, there's nothing before the dot).
If you don't have such a file, create one.
Then, you need to add the following into the .htaccess file.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

(Replace "example.com" with your domain name.)

Do a search for "htaccess redirect" to learn more.
.htaccess is a very useful and important tool in managing a website.

phranque

11:25 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, phrasebase!
also search on "domain name canonicalization" for more information about this.

Phrasebase

12:48 am on Aug 8, 2007 (gmt 0)

10+ Year Member



Thank you both soooooo much!