Page 1 of 1

[solved] Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 12:50 pm
by philipp
Hi folks,

Just got CMSMS setup and really like the experience.  Congrats on a top job :)

This question isn't about SSL, but if someone lands on my site at http://example.com then my SSL seal doesn't show up properly, so I need to redirect them to http://www.example.com before it will appear.

Is there a 'correct' way in CMSMS of redirecting them to www.example.com?  I have been looking at writing a UDT for this but it seemed pretty basic so I guess this is probably already in CMSMS.

Any replies appreciated,

Thanks!

Re: Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 1:02 pm
by nhaack
This is set up with the .htaccess file. There should be enough solutions in the forum or in the internet. Since this is not a specific CMSMS issue, you should be able to find a lot of aswers with your favourite search engine.

Re: Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 2:40 pm
by philipp
Right, this is dead simple - and there's no need to hack around the .htaccess file ;)

I just made a UDT as follows:

if($_SERVER['SERVER_NAME'] == "example.com")
{
    $newurl = 'http://www.example.com/'.$_SERVER['REQUEST_URI'];
    header("Location: $newurl");
    exit();
}

Cool :)

Re: Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 5:06 pm
by JeremyBASS
I'm with nhaack  go the .htaccess route for best success, SEO wise at least (R=301)... look in the tips and tricks.... it's right up there close to top...  hope this helps

Re: Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 5:19 pm
by philipp
Fantastic, thanks Jeremy - really appreciate the pointer.

Here's the link for anyone following: http://forum.cmsmadesimple.org/index.php/topic,27515.0.html

Cheers,

Philip

Re: Redirecting from example.com to www.example.com

Posted: Mon Dec 01, 2008 7:12 pm
by JeremyBASS
Great glad I could help... don't forget to put solved in the main title  ;)


have a great day..
Jeremy