Forum Moderators: phranque
I want my example.com to forward to www.example.com
I have tried everything from just using redirect in htaccess but it throws it into a loop.
How can I make it so that everytime someone visits http://example.com(without www) they get forward to http://www.example.com(with www). Thanks for your help its greatly appreciated, and if you have the answer could you include the code, I am having a rough time with this.
Mark
[edited by: engine at 8:20 pm (utc) on Feb. 6, 2004]
[edit reason] examplified and de-linked [/edit]
we made a virtual host for [example.com...] and then redirect in httpd.conf
Redirect Permanent / "http://www.example.com"
may not be the best way but it works perfectly
<added>some thoughts here too
Indexed with and without "www." prefix [webmasterworld.com]
If both domains use the same server space, you may need to use mod_rewrite to prevent a redirection loop. For httpd.conf:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]