View Full Version : redirect
esthera
02-27-2006, 07:41 PM
How can I check what page was called and then redirect...
meaning that
if the person typed in http://www.mydomain.com
I want it to
<?php
//header("Location: http://mydomain.com");
?>
but only if they put in the www -- if i just do teh redirect automatically then it's an endless loop --
can someone help me with how i know what page was called?
StupidRalph
02-27-2006, 08:59 PM
Can you do a URL Forward from whoever you bought your domain name from?
esthera
02-28-2006, 06:34 AM
not sure -- ther'es no easy way to do in php?
deathseeker25
02-28-2006, 01:15 PM
not sure -- ther'es no easy way to do in php?
Yes i think it is not hard to do: you have to create a variable that will store the input. Then you call the variable in the header.
<?php
$variable=$_POST['input_of_the_user'];
header('Location:'$variable'');
?>
Isn't this working?
gsnedders
02-28-2006, 01:44 PM
<?php
if (strpos($_SERVER['HTTP_HOST'], 'www.') === 0)
{
header("Location: http://mydomain.com$_SERVER[REQUEST_URI]");
}
?>
That'd do it, and the person to the same page as they had requested on www.
degsy
02-28-2006, 02:32 PM
You would be best off doing this at the server level.
Either setup the domain so that it can use www or not.
Or if using Apache set it to redirect all requests of mydomain.com to www.mydomain.com
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.