dlf1987 Posted February 26, 2008 Share Posted February 26, 2008 Hi, how do i detect if the user is logged on to my site through http://www. or just http://? I want to be able to redirect people to http://www. The main reason why im asking is because my cookies from the http:// domain, dont show up on http://www. I think theres a way with apache rewrite, but i run PHP on Windows IIS6 so i dont think rewrite works. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/ Share on other sites More sharing options...
tinker Posted February 26, 2008 Share Posted February 26, 2008 You could use $_SESSION['HTTP_REFERER'] to get the last full address, if it's not your own then you redirect, otherwise you check if it is how you want it. P.S. Use header to redirect Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477362 Share on other sites More sharing options...
dlf1987 Posted February 26, 2008 Author Share Posted February 26, 2008 hmm or is there a way for the same cookie to be read by both http:// and http://www? Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477363 Share on other sites More sharing options...
dlf1987 Posted February 26, 2008 Author Share Posted February 26, 2008 Thanks for the help, but i figured it out from php.net... http://uk3.php.net/manual/pl/function.setcookie.php "To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the » spec for details." Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477380 Share on other sites More sharing options...
revraz Posted February 26, 2008 Share Posted February 26, 2008 You could use .htaccess to forward all traffic to your non www site. Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477388 Share on other sites More sharing options...
tinker Posted February 26, 2008 Share Posted February 26, 2008 You could use $_SESSION['HTTP_REFERER'] to get the last full address, if it's not your own then you redirect, otherwise you check if it is how you want it. P.S. Use header to redirect Sorry, this should of been: $_SERVER['HTTP_REFERER'] Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477393 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Share Posted February 26, 2008 you can do .htacess my webhost has a FAQ and it has that in it, here is what it says: You are able to make your web site always appear with the address www.lamezz.com. Please use the follwoing code in a .htaccess file to redirect your url from lamezz.com to www.lamezz.com. ------------------------------- Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^lamezz.com [NC] RewriteRule (.*)$ http://www.lamezz.com/$1 [L,R=301] ------------------------------- You are able to make this redirection for any of your domain names on your Servage account. since I was logged on with my account it uses www.lamezz.com, just replace it with yours, I have tried it before, and it works! Quote Link to comment https://forums.phpfreaks.com/topic/93176-detect-www/#findComment-477462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.