PDA

View Full Version : Redirect script


BoR|S
04-23-2003, 12:30 PM
I had a redirect script in made using ASP, it worked this way:
Links were of the format: redir.asp?url=http://www.website.com, and the redir.asp itself had the following code:

<%@ Language=VBScript %>
<html>
<head>
<title>Redirect</title>
</head>
<frameset rows="*,52" border="0">
<frame src="<%=Request("url")%>" marginheight="0" marginwidth="0"
scrolling="auto" noresize>
<frame src="bottom.asp" marginheight="0" marginwidth="0"
scrolling="no" noresize>
</frameset>
</html>


Can anyone write me it's translation to PHP and/or suggest me how to improve this script? (Maybe somehow to do it without using frames? With SSI/DHTML?)

Coreyp_1
04-24-2003, 01:25 AM
Boris,

Not much changes in switching over to PHP. Assuming you are accessing the page redir.php?url=http://www.website.com, then the code for the redir.php is as follows:


<html>
<head>
<title>Redirect</title>
</head>
<frameset rows="*,52" border="0">
<frame src="<?=$url?>" marginheight="0" marginwidth="0"
scrolling="auto" noresize>
<frame src="###whatever###" marginheight="0" marginwidth="0"
scrolling="no" noresize>
</frameset>
</html>

Of course, you need to replace the bottom frame source URL with an actual URL.

Other than that, it's quite straitforward.

NarGemini
06-09-2003, 10:39 AM
Of course, if you don't want frames at all you can try this:


<?php

header("Location: " . $url);

?>

NarGemini
06-10-2003, 01:44 PM
Some older versions of PHP may require you to type the entire variable name, too, so $_GET['url'] would be $HTTP_GET_VARS['url']. It is also better to use the longer method for backwards compatibility in the event you want to use the script on another server with software that is less up-to-date.