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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
philipp
Forum Members
Forum Members
Posts: 22
Joined: Mon Dec 01, 2008 12:44 pm

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

Post 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!
Last edited by philipp on Mon Dec 01, 2008 9:23 pm, edited 1 time in total.
nhaack

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

Post 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.
philipp
Forum Members
Forum Members
Posts: 22
Joined: Mon Dec 01, 2008 12:44 pm

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

Post 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 :)
Last edited by philipp on Mon Dec 01, 2008 5:56 pm, edited 1 time in total.
JeremyBASS

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

Post 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
philipp
Forum Members
Forum Members
Posts: 22
Joined: Mon Dec 01, 2008 12:44 pm

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

Post 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
JeremyBASS

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

Post by JeremyBASS »

Great glad I could help... don't forget to put solved in the main title  ;)


have a great day..
Jeremy
Post Reply

Return to “CMSMS Core”