.htaccess trick to insert www
Posted: Wed Nov 12, 2008 5:59 pm
I was having trouble with iCMSUser setting a cookie for the PHPBB forum board and for CMSMS.
The problem I was having was that if you came to the site via http://mysite.com and logged in, then came back to http://www.mysite.com, the cookie didn't set.
So, I found this little snippet of code that will re-write the url to always be http://www.mysite.com.
If someone has a better way, I'd like to hear it
The problem I was having was that if you came to the site via http://mysite.com and logged in, then came back to http://www.mysite.com, the cookie didn't set.
So, I found this little snippet of code that will re-write the url to always be http://www.mysite.com.
If someone has a better way, I'd like to hear it

Code: Select all
RewriteEngine On
#------------code added to default .htaccess file-----------------
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
# ------------------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]