[php] how to?

hi, i wonder how it is made that when i enter http://crossfire.nu/ , it automaticcaly redirects to http://crossfire.nu/?x=home

is it made with <link refresh etc.
or some php expression?

$_GET[x] = "news"; obviously cant work as it doesnt force browser to refresh with including given value of x.

maybe .htacces?
Comments
14
You just make index.html redirecting to that address? :P
http_redirect(adress)
dont get it :/
what about

header("location: http://www.google.de");
arr, this be true
Parent
you used it?

well, i just tried that header() function. there's a problem :/
when i made that one:
header("location: http://google.pl");
it worked (fast).
but when i tried that one:
header("location: http://pentel.ovh.org/?x=home");
site doesnt want to load (loading... forever) :/
Parent
?x=home is just short for index.php?x=home, so wenn u only call crossfire.nu in ur browser, it loads the index page of that directory, that reloads itself with the default value for x set.
edit: or a 303 redirection setup in .htaccess loading index.php?x=home when only index.php is called.
edit2: or just mod_rewrite in work / i stop thinkin about how many ways u could setup that now, my brain goes in circles already ( /me walks away mumblin to himself rippin off his hairs :S)
ok but which way is the fastest and the least resources-eating one? :)
Parent
if i would code the script i would do smth like

switch ($_GET['x'])
{
case "news":
do_smth();
break;
case "whatever":
do_smthelse();
break;
default:
do_smth();
break;
}


u wont have it visible in the url then, but it doesnt use any apache extensions to give the results. else just mod_redirect in .htaccess(u wont notice anything in speed even with higher loaded websites).
Parent
thats not what i asked about. i include subpages with simple if/else, so thats no problem.

if ($x == ""){
$x = "home";
}
if(file_exists($includedir . "$x" . ".php")){
include($includedir . "$x" . ".php");
} else {
$x = "home";
}

(where $x == $_GET[x])

i was wondering how page is immediately set to ?x=news. i think ill just use header("location
Parent
"... else just mod_redirect in .htaccess(u wont notice anything in speed even with higher loaded websites). "
mod_rewrite i meant :S
Parent
rofl @ Adi =)
Or just use a html script for your index.html

<html>
<head>
<meta http-equiv="refresh" content="20; URL=http://web7.alpha187.server4you.de//">
<meta name="keywords" content="automatic redirection">
</head>
<body>
If your browser doesn't automatically go there within a few seconds,
click <a href="http://web7.alpha187.server4you.de//">here</a>
manually.
</body>
</html>

Or if you want it in a new browser window:

<script language="javascript" type="text/javascript">
window.setTimeout('window.open("http://web7.alpha187.server4you.de//","newsite")',4500);
</script>


Choose the script that u want :) I hope it helps u, HF !
Back to top