PHP Redirect to www.
1) CODE TITLE: Simple Redirect
2) AUTHOR NAME/NOTES:
3) DESCRIPTION: Redirect a user to the www. of your page so cookies will function correctly regardless of how they navigated there.
4) URL TO CODE:
or, ATTACHED BELOW (see #3 in guidelines below):
PHP Code:
if (!preg_match('/www\..*?/', $_SERVER['HTTP_HOST'])) {
if(!EMPTY($_SERVER['QUERY_STRING']))
header("location: http://www." . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
else
header("location: http://www." . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
Corrections to my coding/thoughts welcome.
Bookmarks