Jump to content

PHP Redirect to new website?


JustinMs66@hotmail.com

Recommended Posts

i know that this is how you redirect to a file on your website:
[code]header("location: include/install.php");[/code]
but if i wanted to go to another website completely, how would i do that?

because when i try it like this:
[code]header("location: http://www.google.com/");[/code]
it says:

[color=purple]Warning: Cannot modify header information - headers already sent by (output started at /www/locate1.php:9) in /www/locate1.php on line 10[/color]

and line 10 is that headers line that i made.

please help!??
Link to comment
Share on other sites

In fact having [code]<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
header("location: http://www.google.com/");
?>
</body>
</html>[/code] is stupid since the HTML will never be seen.

[code]<?php
header("location: http://www.google.com/");
?>[/code] would be enough.
Link to comment
Share on other sites

For redirections, you could show the user that they are being redirected.

Try this code:
[code]<?php
header("Location: http://www.google.com/");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Redirection ...</title>
</head>
<body>
You are being redirected to <a href="http://www.google.com">Google</a>.
</body>
</html>[/code]

Of course, besides PHP, you can also do a meta-tag redirect or a javascript redirect.
Link to comment
Share on other sites

[quote author=pkSML link=topic=109142.msg439961#msg439961 date=1159024861]
For redirections, you could show the user that they are being redirected.

Try this code:
[code]<?php
header("Location: http://www.google.com/");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Redirection ...</title>
</head>
<body>
You are being redirected to <a href="http://www.google.com">Google</a>.
</body>
</html>[/code]

Of course, besides PHP, you can also do a meta-tag redirect or a javascript redirect.
[/quote]
WHats the point in that! The user isnt going to see anything. The user will be redirected straight away!
Link to comment
Share on other sites

They will only see the HTML for a small period of time (the time it takes for a DNS query for www.google.com to be completed, the request to be made to Google, and information from Google to be sent to the browser and displayed).

All in all, they will see the page for a split-second, unless something goes wrong on the client's end. Then they know what is supposed to be happening.

Anyways, this is Justin's decision. Just giving more options.  :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.