Hello, the thing i trying to do is to add to index.php file code what will check for cookie and depending on it will redirect: if (isset($_COOKIE["welcomepage"])) header("Location: ./index.php?welcome"); else header("Location: ./index.php?mainpage"); if ($_SERVER["QUERY_STRING"] == "welcome"){ setcookie("welcomepage", "view", time()+43200); echo "Welcome!."; } PHP: but what causes "Redirect Loop", because all other pages are in same index.php , ore included. my goal is to make page what will look like all is in one index.php and all other pages will be index.php?something , cuz not all pages will be really in index.php, whey will be included. So any ideas how to fix what problem?
why not changing ?mainpage to ?page=mainpage, so you can check if $_GET['page'] is used before you do a redirect! for example if (!isset($_COOKIE["welcomepage"])) { // display first screen and add cookie setcookie("welcomepage", "view", time()+43200); echo 'hello world'; } else { switch ($_SERVER['QUERY_STRING']) { case "welcome": break; default: break; } } Code (markup):
Yes, all works fine, thanks! But if user will just view index.php... because all in $_SERVER['QUERY_STRING'] if i add redirect, it will cause redirect loop, because what code i will add will be everywhere! Any ideas?
well basically, SEO Friendly URLs are, something like instead of xxx.com/index.php?page=xxx They will be xxx.com/page/xxx An example that I have used is at freebetsgalore.com. Have a look at the urls. All those pages dont actually exist, but it appears in the urls as if they are actual pages / directories.
damit, and why is better to use index.php?page=xxx instead of index.php?xxx ??? you mean longer urls are better?
Eh! Not really that... see page=xxx is available through $_GET['page'] while for ?xxx, you will have to iterate through teh $_GET varaible. This is the standard method used by most of the programmers