Announcement

Collapse
No announcement yet.

Simple redirect from domain.com to www.domain.com

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple redirect from domain.com to www.domain.com

    I searched the forum for this answer, but couldn't find it, so I'm not sure if anyone has ever posted it.

    For some reason, if I go into options and set my cookie domain to .domain.com the cookies get royally screwed up and no one is able to log out. The only reason I'd want to set the cookies like this would be so the cookie is recognizable at both domain.com and www.domain.com.

    As doing things that way doesn't seem to work for me, my only other alternative is to just automatically redirect users visiting domain.com to www.domain.com (I noticed it's done on the vbulletin.com page)

    I did some searching and some suggested to place it in the global.php, however this doesn't work for me at all. So I went into my templates and placed the following inside the pminclude template (one I've found VERY valuable!!)

    Just thought I'd share in case anyone else is having this problem or seeking this solution. Here's the code, I just placed it at the top of the pminclude template:

    PHP Code:
    $thisroot $HTTP_SERVER_VARS['HTTP_HOST'];
    $thisphp_self $_SERVER['PHP_SELF'];

    if (
    substr($thisroot,0,4) != "www.")
         
    header("location: http://www.domain.com{$thisphp_self}"); 
Loading...
Working...
X