How can I get the redirected address as a variable?

Discussion in 'PHP' started by reza1217, Apr 18, 2008.

  1. #1
    Hi guys,
    A little help would be appreciated on the following matter.

    I am trying to work with a URL that gets redirected to another URL which is random. I would like to get that address and work with it. For example:

    $site = "http://example.com/";

    this is my URL but when the page is loaded it is from an address "http://example.com/content/some/other/directory/"

    What I would like to do is get something like
    $new_site="http://example.com/content/some/other/directory/";

    Any ideas??

    Really appreciate your help. Thank You.
     
    reza1217, Apr 18, 2008 IP
  2. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use this to have random links. First, create a text file lamed "links.txt". In that, enter your links, one per line with the text "NEWLINKNEWLINK" between each link like so:

    http://google.com
    NEWLINKNEWLINK
    http://yahoo.com
    NEWLINKNEWLINK
    http://msn.com
    NEWLINKNEWLINK
    http://fart.com

    
    <?php
    
    	if (file_exists("./links.txt")) {
    		srand((double)microtime()*1000000); 
    		$array_ad = spliti("NEWLINKNEWLINK",join('',file("./links.txt"))); 
    		$link = $array_ad[rand(0,sizeof($array_ad)-1)];
    	} else {
    		$link = 'SET STATIC LINK IN CASE THERE ARE NO LINKS.';
    	}
    
    
    ?>
    
    PHP:
     
    phpl33t, Apr 18, 2008 IP
  3. reza1217

    reza1217 Peon

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am not sure if this solves my problem. Anyway I am going to be more clear on what I am trying to do.
    I am trying to fetch information from the reference website($site="http://example.com/";) which gets redirected to another URL within the same site(http://example.com/some/other/directory/";). What I want to do is get that redirected URL saved as a variable and work with it instead of the initial one($site). Basically I am trying to fetch news using regexp statements.

    Any Ideas? Thanks.
     
    reza1217, Apr 18, 2008 IP
  4. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ah, ok. my bad. lol
     
    phpl33t, Apr 19, 2008 IP