1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Which redirect method?

Discussion in 'PHP' started by phree_radical, Oct 31, 2006.

  1. #1
    Which redirect is recommended? I want to mask the link (example: AzoogleAds) and also keep some tracking info (not shown).

    Method 1, Header
    <?php
    	$dest = $_REQUEST['dest'];
    
    	header('Cache-Control: no-cache, must-revalidate');
    	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    	header("Location: $dest");
    ?>
    PHP:
    Method 2, Meta Refresh
    <?php
    	$dest = $_REQUEST['dest'];
    	if(!strlen($dest)) die('You fools!');
    
    	print <<<END
    
    <html>
    	<head>
    		<meta http-equiv="refresh" content="0;$dest">
    	</head>
    	<body>
    		<a href="$dest">Proceed manually &raquo;</a>
    	</body>
    </html>
    
    END;
    ?>
    PHP:
    Method 3, Iframe
    <?php
    	$dest = $_REQUEST['dest'];
    
    	print <<<END
    
    <html>
    	<head>
    		<title>You are Here.</title>
    		<style>
    			body { margin: 0; }
    			iframe {
    				margin: 0;
    				width: 100%;
    				height:100%;
    				border: 0;
    			}
    		</style>
    	</head>
    	<body>
    		<iframe src="$dest"></iframe>
    	</body>
    </html>
    
    END;
    ?>
    PHP:
    Method 4, Javascript window.location.href
    <?php
    	$dest = $_REQUEST['dest'];
    
    	print <<<END
    
    <html>
    	<head>
    		<script language = "javascript">
    			window.location.href='$dest';
    		</script>
    	</head>
    </html>
    
    END;
    ?>
    PHP:
    Any other methods?
     
    phree_radical, Oct 31, 2006 IP
    vishwaa likes this.
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    header("HTTP/1.1 301 Moved Permanently"); 
    header("Location: http://www.xxx.co.uk"); 
    exit();
    PHP:
     
    mad4, Nov 1, 2006 IP
  3. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #3
    If you're masking the URL, I wouldn't use the 301 header as any automated scripts (like search engines) will go directly to the URL that's supposed to be masked after getting the 301.
     
    sketch, Nov 1, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you don't want the engines to follow it just cloak the link in your redirect script.
     
    mad4, Nov 2, 2006 IP
  5. Joseph S

    Joseph S Well-Known Member

    Messages:
    1,373
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #5
    Yup, I suppose that`s the best way. If you will use 301 search engines will jump to the new URL
     
    Joseph S, Nov 6, 2006 IP