Redirecting a URL...?
Hello fellow webmasters! I have been out here everyone now and then, but I have a question. We are currently working on a website dedicated to Microsoft's games. We would like the ability to redirect a certain URL to another URL without the visitor having to wait for the redirect for even a second. Does anyone know how this is done through a code or some other means? I would greatly appreciate a response!
Thanks once again!
Robby
nike_guy_man posted this at 03:49 — 22nd November 2002.
They have: 840 posts
Joined: Sep 2000
You can use the header() function in PHP if you have support for PHP
http://www.php.net/manual/en/function.header.php
<?php
The second special case is the \"Location:\" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless some 3xx status code has already been set.
header(\"Location: <a href=\"http://www.example.com/\" class=\"bb-url\">http://www.example.com/</a>\"); /* Redirect browser */
exit; /* Make sure that code below does
not get executed when we redirect. */
?>
You can use Meta refresh in HTML, but that is on a delay
zollet posted this at 03:52 — 22nd November 2002.
He has: 1,016 posts
Joined: May 2002
Create a file called "redirect.php", inside it put...
<?php
header("Location: $_REQUEST[url]");
?>
Then you simply link to the file... request.php?url=http://www.microsoft.com/ which will send the user to M$ website, or request.php?url=http://www.google.com/ which will send the user to google.
Renegade posted this at 09:42 — 22nd November 2002.
He has: 3,022 posts
Joined: Oct 2002
...what?
Suzanne posted this at 15:45 — 22nd November 2002.
She has: 5,507 posts
Joined: Feb 2000
I guess it's possible to answer a question too clearly! lol!
Create a file called request.php. That file should only have this in it:
<?php
header(\"Location: $_REQUEST[url]\");
?>
Then, on the pages where you want to redirect people to another url from your page, put:
microsoft
instead of:
microsoft
Why?
Well, in this case, you could add more options to request.php to track hits to that link, and then you could display on your page how many times someone clicked from your page to microsoft.
However, I think that KnightRobby was asking a slightly different question?
If the page the people land on isn't the one you want them to stay on, you can use a meta refresh of 0 seconds (but there is a perceptile delay), or you can put, on the page you don't want them to stay on, the php snip redirecting them to the correct page.
I believe that someone just asked this question here in this forum to display two different headers depending on what site someone came from.
Is that accurate KnightRobby?
(And, Zollet, thanks, I have been meaning to research the ?url= part for ages!)
Renegade posted this at 04:20 — 23rd November 2002.
He has: 3,022 posts
Joined: Oct 2002
o ok i think i get it now :S
zollet posted this at 06:43 — 23rd November 2002.
He has: 1,016 posts
Joined: May 2002
You are more than welcome
openmind posted this at 15:10 — 23rd November 2002.
He has: 945 posts
Joined: Aug 2001
Just for a bit of variety!
In ColdFusion:
<cflocation="www.whateverurl.com">
Always more than one way!
KnightRobby posted this at 22:13 — 23rd November 2002.
They have: 71 posts
Joined: Sep 2002
Okay, I tried the code and I get something called a "parse error." And I am not sure if you all may know exactly what I am asking:
Let's say a visitor goes to webquad.com When they reach that page, I want it to immediately forward or redirect them to, as an example, Microsft.com How do I go about doing this properly? If your coding is right, sorry, but I am getting an error still...and a simple link on the page...?
Thanks for the replies!
Robby
Busy posted this at 22:25 — 23rd November 2002.
He has: 6,151 posts
Joined: May 2001
what does the error say
and what version of PHP are you using?
zollet posted this at 02:37 — 24th November 2002.
He has: 1,016 posts
Joined: May 2002
Robby,
Edit your index.php and on the first line type...
<?php
header("Location: <a href="http://www.newdomain.com/directory/"" title="http://www.newdomain.com/directory/"">http://www.newdomain.com/directory/"</a>);
?>
Change the URL in blue to the URL of your choice.
Renegade posted this at 02:03 — 14th January 2003.
He has: 3,022 posts
Joined: Oct 2002
Umm just to revive this thread again,
In request.php I have the following:
<?php
header(\"Location:$_REQUEST['url']\");
?>
And in index.php I have this line of coding :
<?php
<p class=\"text\">The new site can be found here: <a href=\"request.php?url=http://impactdesignz.webpros.co.nz/nethelp\" class=\"link\">Here</a></p>
?>
What have I done wrong? It comes up with this error when the link is clicked on :
dk01 posted this at 13:24 — 14th January 2003.
He has: 516 posts
Joined: Mar 2002
Anyone correct me on this one but wouldn't you use:
<?php
header(\"Location: $_GET['url']\");
?>
or
<?php
header(\"Location: $url\");
?>
Make sure you have a space in between Location: and the url.
-dk
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.