Page 1 of 1

How to redirect to WWW

Posted: Sat Mar 18, 2006 7:50 pm
by jonwondering
Hi, I was wondering if it's possible to redirect the user from "http://mysite.com" to "http://www.mysite.com" ? Is there a way to do it?

Thanks,
jonwondering

Posted: Sat Mar 18, 2006 8:00 pm
by feyd
header('Location: ....')

or if you're running Apache, mod_rewrite can do it.

Posted: Sat Mar 18, 2006 8:30 pm
by jonwondering
right, but if I just put it there by itself:

header('Location: http://www.mysite.com');

won't it just keep redirecting to itself forever? or at least something bad will happen? :)

Posted: Sat Mar 18, 2006 8:32 pm
by feyd
You'll have to write the code to figure out what domain the user is on.

Hint: look at $_SERVER

Posted: Sat Mar 18, 2006 8:48 pm
by jonwondering
oh yeah, i havent thought about checking domain... duh, lol. i was thinking about going into variables, but that'd be too messy
thanks feyd!