Jump to content

How To Make More Than One Redirection with PHP on the same page?


Darkwoods

Recommended Posts

Hey im trying to do a direction page where it open differently link direction  pages every time somebody enter it..

 

like this for example any good hint on how to do this?

<?php

header( 'Location: http://www.site1.com/new_page.html' ) ;

header( 'Location: http://www.site2.com/new_page.html' ) ;

header( 'Location: http://www.site3.com/new_page.html' ) ;

?>

Link to comment
Share on other sites

Are you asking?:

 

How do I redirect to a random link every time the page is viewed?

 

yes please how can i do that?

 

Easy and fun..:'

<?php
$rand = rand(1,3); //For random selection
if ($rand == "1") { 
header( 'Location: http://www.site1.com/new_page.html' ) ;
} elseif ($rand == "2") {
header( 'Location: http://www.site2.com/new_page.html' ) ;
} else {
header( 'Location: http://www.site3.com/new_page.html' ) ;
}
?>

 

Simple enough, eh?

Link to comment
Share on other sites

This method is simpler, more versatile and syntactically correct.

 

<?php 
$arr = array(
    'http://www.site1.com/new_page.html',
    'http://www.site2.com/new_page.html',
    'http://www.site3.com/new_page.html'
); 
header('Location: '. $arr[rand(0,count($arr)-1)]) ;
?>

Link to comment
Share on other sites

This method is simpler, more versatile and syntactically correct.

 

<?php 
$arr = array(
    'http://www.site1.com/new_page.html',
    'http://www.site2.com/new_page.html',
    'http://www.site3.com/new_page.html'
); 
header('Location: '. $arr[rand(0,count($arr)-1)]) ;
?>

 

So is your mother

Link to comment
Share on other sites

This method is simpler, more versatile and syntactically correct.

 

<?php 
$arr = array(
    'http://www.site1.com/new_page.html',
    'http://www.site2.com/new_page.html',
    'http://www.site3.com/new_page.html'
); 
header('Location: '. $arr[rand(0,count($arr)-1)]) ;
?>

 

So is your mother

 

Well said.

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.