![]() |
|
|
|
#1 |
|
On one of my sites I use
<? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to forward people that goto http://www.MYDOMAIN.com to that page. Now is there a way to make it randomly pick a file to send to? Like <? $num = $rand(1,3) header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> Where $rand would pick 1 2 or 3 then send the user to that index page? Viper |
|
|
|
|
#2 |
|
Posts: n/a
|
Viper wrote:
> On one of my sites I use > <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to > forward people that goto http://www.MYDOMAIN.com to that page. Now is > there a way to make it randomly pick a file to send to? > > Like > <? > $num = $rand(1,3) > header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> > Where $rand would pick 1 2 or 3 then send the user to that index page? Yes. http://www.php.net/rand "int rand ( [int min, int max]) If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15)." -- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ Chris Hope |
|
|
|
#3 |
|
Posts: n/a
|
Chris Hope wrote:
> Viper wrote: > >> On one of my sites I use >> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to >> forward people that goto http://www.MYDOMAIN.com to that page. Now is >> there a way to make it randomly pick a file to send to? >> >> Like >> <? >> $num = $rand(1,3) >> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> >> Where $rand would pick 1 2 or 3 then send the user to that index >> page? > > Yes. > > http://www.php.net/rand > > "int rand ( [int min, int max]) > > If called without the optional min, max arguments rand() returns a > pseudo-random integer between 0 and RAND_MAX. If you want a random > number between 5 and 15 (inclusive), for example, use rand (5, 15)." Thanks that helped a bit. This works: <? $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; header("location: $newpage") ;?> Viper |
|
|
|
#4 |
|
Posts: n/a
|
Viper wrote:
> Chris Hope wrote: >> Viper wrote: >> >>> On one of my sites I use >>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to >>> forward people that goto http://www.MYDOMAIN.com to that page. Now >>> is there a way to make it randomly pick a file to send to? >>> >>> Like >>> <? >>> $num = $rand(1,3) >>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> >>> Where $rand would pick 1 2 or 3 then send the user to that index >>> page? >> >> Yes. >> >> http://www.php.net/rand >> >> "int rand ( [int min, int max]) >> >> If called without the optional min, max arguments rand() returns a >> pseudo-random integer between 0 and RAND_MAX. If you want a random >> number between 5 and 15 (inclusive), for example, use rand (5, 15)." > > Thanks that helped a bit. > This works: > > <? > $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; > header("location: $newpage") > > ;?> You could also do something like this, although there's a little more overhead involved as it has to initiate the array and use memory: $pages = array( "somepage.php", "anotherpage.php", "someotherpage.php" ... ); $rand = rand(0, sizeof($pages)-1); $newpage = "http://www.MYDOMAIN.com/pages/" . $pages[$rand]; header("location: $newpage"); exit; -- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ Chris Hope |
|
|
|
#5 |
|
Posts: n/a
|
Viper wrote:
> Chris Hope wrote: >> Viper wrote: >> >>> On one of my sites I use >>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to >>> forward people that goto http://www.MYDOMAIN.com to that page. Now is >>> there a way to make it randomly pick a file to send to? >>> >>> Like >>> <? >>> $num = $rand(1,3) >>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> >>> Where $rand would pick 1 2 or 3 then send the user to that index >>> page? >> >> Yes. >> >> http://www.php.net/rand >> >> "int rand ( [int min, int max]) >> >> If called without the optional min, max arguments rand() returns a >> pseudo-random integer between 0 and RAND_MAX. If you want a random >> number between 5 and 15 (inclusive), for example, use rand (5, 15)." > > Thanks that helped a bit. > This works: > > <? > $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; > header("location: $newpage") > > ;?> Well done that man! Looks neat. -- Charles Sweeney http://CharlesSweeney.com Charles Sweeney |
|
|
|
#6 |
|
Posts: n/a
|
Charles Sweeney wrote:
> Viper wrote: > >> Chris Hope wrote: >>> Viper wrote: >>> >>>> On one of my sites I use >>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> >>>> to forward people that goto http://www.MYDOMAIN.com to that page. >>>> Now is there a way to make it randomly pick a file to send to? >>>> >>>> Like >>>> <? >>>> $num = $rand(1,3) >>>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> >>>> Where $rand would pick 1 2 or 3 then send the user to that index >>>> page? >>> >>> Yes. >>> >>> http://www.php.net/rand >>> >>> "int rand ( [int min, int max]) >>> >>> If called without the optional min, max arguments rand() returns a >>> pseudo-random integer between 0 and RAND_MAX. If you want a random >>> number between 5 and 15 (inclusive), for example, use rand (5, 15)." >> >> Thanks that helped a bit. >> This works: >> >> <? >> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; >> header("location: $newpage") >> >> ;?> > > Well done that man! Looks neat. Thanks but now I have to wonder how search engines will handle it. See what I am planning to do is take all the domains I own that have no pages on them and make up "portal" pages using PPC Search engines. I want it to show a different portal page that has a different set of PPC Search engines links on it each time they visit. But will Google, etc even list these pages? Viper |
|
|
|
#7 |
|
Posts: n/a
|
Viper wrote:
> Charles Sweeney wrote: >> Viper wrote: >> >>> Chris Hope wrote: >>>> Viper wrote: >>>> >>>>> On one of my sites I use >>>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> >>>>> to forward people that goto http://www.MYDOMAIN.com to that page. >>>>> Now is there a way to make it randomly pick a file to send to? >>>>> >>>>> Like >>>>> <? >>>>> $num = $rand(1,3) >>>>> header("location: >>>>> http://www.MYDOMAIN.com/pages/index$rand.php");?> Where $rand >>>>> would pick 1 2 or 3 then send the user to that index page? >>>> >>>> Yes. >>>> >>>> http://www.php.net/rand >>>> >>>> "int rand ( [int min, int max]) >>>> >>>> If called without the optional min, max arguments rand() returns a >>>> pseudo-random integer between 0 and RAND_MAX. If you want a random >>>> number between 5 and 15 (inclusive), for example, use rand (5, >>>> 15)." >>> >>> Thanks that helped a bit. >>> This works: >>> >>> <? >>> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; >>> header("location: $newpage") >>> >>> ;?> >> >> Well done that man! Looks neat. > > Thanks but now I have to wonder how search engines will handle it. See > what I am planning to do is take all the domains I own that have no > pages on them and make up "portal" pages using PPC Search engines. I > want it to show a different portal page that has a different set of > PPC Search engines links on it each time they visit. But will Google, > etc even list these pages? As I understand it, when using a redirection, Google will index the page it gets sent to, but drop the sending page. -- Charles Sweeney http://CharlesSweeney.com Charles Sweeney |
|
|
|
#8 |
|
Posts: n/a
|
"Charles Sweeney" <> wrote in message news:Xns95C16A020C173mecharlessweeneycom@130.133.1 .4... > Viper wrote: > >> Charles Sweeney wrote: >>> Well done that man! Looks neat. >> >> Thanks but now I have to wonder how search engines will handle it. See >> what I am planning to do is take all the domains I own that have no >> pages on them and make up "portal" pages using PPC Search engines. I >> want it to show a different portal page that has a different set of >> PPC Search engines links on it each time they visit. But will Google, >> etc even list these pages? > > As I understand it, when using a redirection, Google will index the page > it gets sent to, but drop the sending page. > AFAIK that's only if Google knows it is a redirection - i.e. if you're sending the proper headers while redirecting. Would googlebot know if Viper's site is redirecting it? -- -Karl Core Please Support "Project Boneyard": http://www.insurgence.net/info.aspx?...&item=boneyard Karl Core |
|
|
|
#9 |
|
Posts: n/a
|
On Thu, 16 Dec 2004 08:55:40 -0500, Karl Core wrote:
> AFAIK that's only if Google knows it is a redirection - i.e. if you're > sending the proper headers while redirecting. > Would googlebot know if Viper's site is redirecting it? Probably. PHP is pretty decent about complying with header standards. -- Jeffrey D. Silverman | Website | http://www.newtnotes.com Drop "PANTS" to reply by email Jeffrey Silverman |
|
|
|
#10 |
|
Posts: n/a
|
Viper wrote:
> Charles Sweeney wrote: > >>Viper wrote: >> >> >>>Chris Hope wrote: >>> >>>>Viper wrote: >>>> >>>> >>>>>On one of my sites I use >>>>><? header("location: http://www.MYDOMAIN.com/pages/index.php");?> >>>>>to forward people that goto http://www.MYDOMAIN.com to that page. >>>>>Now is there a way to make it randomly pick a file to send to? >>>>> >>>>>Like >>>>><? >>>>>$num = $rand(1,3) >>>>>header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?> >>>>>Where $rand would pick 1 2 or 3 then send the user to that index >>>>>page? >>>> >>>>Yes. >>>> >>>>http://www.php.net/rand >>>> >>>>"int rand ( [int min, int max]) >>>> >>>>If called without the optional min, max arguments rand() returns a >>>>pseudo-random integer between 0 and RAND_MAX. If you want a random >>>>number between 5 and 15 (inclusive), for example, use rand (5, 15)." >>> >>>Thanks that helped a bit. >>>This works: >>> >>><? >>>$newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php"; >>>header("location: $newpage") >>> >>>;?> >> >>Well done that man! Looks neat. > > Thanks but now I have to wonder how search engines will handle it. See what > I am planning to do is take all the domains I own that have no pages on them > and make up "portal" pages using PPC Search engines. I want it to show a > different portal page that has a different set of PPC Search engines links > on it each time they visit. But will Google, etc even list these pages? Depending on how your files are set up, instead of doing a redirect with headers, you could use an include or an fpassthru call. That way, the content is displayed without a redirect... -- Justin Koivisto - http://www.koivi.com Justin Koivisto |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Dial-up Modem Question | w_tom | A+ Certification | 0 | 09-18-2005 09:12 PM |
| "Installing two drives" question - what next? | Jim | A+ Certification | 12 | 08-07-2005 01:19 PM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | God | DVD Video | 3 | 04-25-2005 04:19 PM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | Filthy Mcnasty | DVD Video | 0 | 04-25-2005 04:29 AM |
| Re: Safe Mode Question (A+ question) | Gordon Findlay | A+ Certification | 0 | 06-16-2004 10:48 AM |