SRL Archive - Web Development

Redirecting??? Help?


Timer

2007-12-22 17:17:12

how would i make a link re-direct you.. like

thanks in advance

http://www.moparisthebest.com/no.html
redirects u to
http://www.moparisthebest.com/deathpick.png

Jason2gs

2007-12-22 17:30:33

[PHP]
<?php
header("Location: http://www.moparisthebest.com/deathpick.png");
?>
[/PHP]

Or

[PHP]
<?php
$page = $_GET['p'];
header("Location: $page");
?>
[/PHP]

Depending on if you want the script to accept just any page, or if it's built for one page and one page alone.

And what's with all of these redirection requests lately? Lemme guess: Trying to find the leaker? :rolleyes:

Timer

2007-12-22 17:41:46

so, for example, on these forums, in the first post i would put

<?php
header("Location: my page");
?>

and when every someone would click to goto that forum it would re-direct, or how would i do it?

Jason2gs

2007-12-22 17:46:16

Heh :p

No, doesn't exactly work that way. If it did, everybody would be doing it.

You need free (or not so free, but free is cheaper :)) hosting that has PHP installed. You upload that script in a .php file, and you can execute it by hitting the page.

Like:

http://timer.freehostia.com/Redirect.php?p=http://www.google.com

Would redirect to Google.com, if you used the second script that grabbed the page from the URL.

And again, what is this used for?

Timer

2007-12-22 17:51:45

oh i wanna try sumthing, and for leaking too lol, does freehosta have it?

Jason2gs

2007-12-22 17:54:36

Sure does :)

Has probably one of the best free PHP & MySQL hosting plans around.

Jason2gs

2007-12-22 17:59:12

And if you weren't aware, you can also grab the IP of the person that hits the page too. Very easily.

[PHP]
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_GET['p'];
?>
[/PHP]

Heck, you could hide the script in a png and simply send the guy a picture to look at. Just a matter of modifying the content-type header.

Timer

2007-12-22 18:02:08

ok i dont get it what do i do now that i have an account???

how will i make it so once they visit here it redirects them?

Jason2gs

2007-12-22 18:14:01

Visits -here-? You can't do that. You can't make it redirect from this page. You have to have rights to the PHP file.

You can put a image on here and get his IP that way.

Timer

2007-12-22 18:18:04

okok, i upload a file with .php and have the line have /"name".php??

Jason2gs

2007-12-22 18:20:22

What line?

Timer

2007-12-22 18:22:49

<?php
$ip = $_SERVER['REMOTE_ADDR'];
header("Location: my link");
?>

Jason2gs

2007-12-22 18:25:29

"my link" is the full URL to the page you want to redirect to. And if you're not going to be stealing their IP, you don't need the second line there.

Timer

2007-12-22 18:30:25

ok, and 1 more thing, could this could be used for like for ref sites like can u have

[PHP]<?php
header("Location: my link");
header("Location: my link");
?>[/PHP]

or would i need a "php wait" so that the first header can load? lol

Jason2gs

2007-12-22 18:35:49

The header function sends a certain header value to the browser. If you send one Location header value, the current page is changed to whatever you set as the Location header's value. When the page changes, the PHP script is killed, so the script would never get to go on with the next command. [Which is, in this case, header();]

Timer

2007-12-22 18:54:15

is there a way like scars getpage? so it can procede to the next one?

Jason2gs

2007-12-22 18:56:28

You could make a popup window, but FF - for the most part - blocks them.

munk

2007-12-22 19:19:43


<meta http-equiv="refresh" content="0;url=http://whatever.com">
content is the seconds to wait before redirect.

<script type=text/javascript>
window.location = "http://www.whatever.com/";
// or
window.location.replace = "http://www.whatever.com/";
</script>
the second one will redirect the page without putting the intial page into history. This is good for when a user hits the back button it wont go to the initial redirect page and try to redirect again.

just some other non-PHP ways:)

Timer

2007-12-22 19:28:48

From: Jason2gs
You could make a popup window, but FF - for the most part - blocks them.


how to make a pop-up?

munk

2007-12-22 19:40:01

uhh somethin like

<script type=text/javascript>
window.open = "http://www.whatever.com/";
</script>
i believe thats it. Ill loook it up and give ya a link in a sec. I know theres a crapload of parameters to define how you want the popup to look.

EDIT: http://www.webreference.com/programming/javascript/diaries/7/2.html

R0b0t1

2007-12-24 21:08:02

[script]
window.popup("search for arguments");
[/script]