Mr. Black Posted November 18, 2014 Share Posted November 18, 2014 Hey guys, I used to have (and can't find it anymore) a script years ago that I need again that does redirection. Example: website.com/redirect.php?4043 4043 would be a URL in a file like links.txt that the script would reference. It's like how Microsoft used to use on their site years ago. Does anyone know where I can something like this? Much appreciated! Link to comment Share on other sites More sharing options...
0 TAZMINATOR Posted November 18, 2014 Share Posted November 18, 2014 You mean something like this: domain.com/page/?redirectid=6 that will take the user to the page based on id, is what you want? If so, you can use either make it up or get the already-made redirect script. make it up means you can write on your own, something like this: if $redirectid == "404" code goes here based on id such as 404 as mentioned above. if $redirectid == "500" place code here based on id... Link to comment Share on other sites More sharing options...
0 +theblazingangel MVC Posted November 18, 2014 MVC Share Posted November 18, 2014 http://php.net/manual/en/function.header.php Link to comment Share on other sites More sharing options...
0 Mr. Black Posted November 18, 2014 Author Share Posted November 18, 2014 Thanks for the responses, I could write it I suppose, but i'd rather have something ready made. Anyone know of one? Link to comment Share on other sites More sharing options...
0 Mr. Black Posted November 18, 2014 Author Share Posted November 18, 2014 Well I wasn't able to find what I wanted, so I wrote it up. Here you all go if you need it: <?php$links = parse_ini_file('urllist.txt');if(isset($_GET['go']) && array_key_exists($_GET['go'], $links)){ header('Location: ' . $links[$_GET['go']]);}else{ header('Location: http://www.website.com/404.htm');} ?> Link to comment Share on other sites More sharing options...
0 Seahorsepip Veteran Posted November 18, 2014 Veteran Share Posted November 18, 2014 Took me less then a sec... works with http://domain.com/redirect.php?code Edit: you were quicker :p <?php $input = ""; $input = key($_GET); $u = array(); //Feel free to add urls with codes below $u[404] = "http://example.com"; $u[666] = "http://neowin.net"; $u[000] = "http://google.com"; $u["youtube"] = "http://yt.be"; foreach($u as $code => $url) { if($code === $input) { header("Location: $url"); die(); } } ?> Well I wasn't able to find what I wanted, so I wrote it up. Here you all go if you need it: <?php $links = parse_ini_file('urllist.txt'); if(isset($_GET['go']) && array_key_exists($_GET['go'], $links)){ header('Location: ' . $links[$_GET['go']]); } else{ header('Location: http://www.website.com/404.htm'); } ?> I like the way you used array_key_exists instead of loop :D Mr. Black 1 Share Link to comment Share on other sites More sharing options...
0 TAZMINATOR Posted November 18, 2014 Share Posted November 18, 2014 Well I wasn't able to find what I wanted, so I wrote it up. Here you all go if you need it: <?php $links = parse_ini_file('urllist.txt'); if(isset($_GET['go']) && array_key_exists($_GET['go'], $links)){ header('Location: ' . $links[$_GET['go']]); } else{ header('Location: http://www.website.com/404.htm'); } ?> Good job! Mr. Black 1 Share Link to comment Share on other sites More sharing options...
Question
Mr. Black
Hey guys,
I used to have (and can't find it anymore) a script years ago that I need again that does redirection.
Example: website.com/redirect.php?4043
4043 would be a URL in a file like links.txt that the script would reference.
It's like how Microsoft used to use on their site years ago.
Does anyone know where I can something like this?
Much appreciated!
Link to comment
Share on other sites
6 answers to this question
Recommended Posts