PHP vs Javascript multiple url redirect script preferences and why

Discussion in 'Programming' started by timothywcrane, Feb 13, 2010.

  1. #1
    :confused:

    I have two scripts for multiple random url redirection that I am looking at to use for affiliate link replacement for all of my keyword backlinks. One of them is written in javascript and the other in PHP. I am not trying to start a flame war, so give technical reasons for your responses. Which one would seem preferable, and why.
     
    timothywcrane, Feb 13, 2010 IP
  2. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #2
    I would use the PHP since Javascripts can be disabled. However it´s a downside to PHP redirect aswell, it can´t be used if the headers was already sent.

    When i redirect someone on my sites i use a combination of redirects:

    
    
    function RedirectTo($website) {
            //Check if php redirect is possible
    	if(!headers_sent())
    		header('refresh: 0;url='.$website);
    		else 
                           // Post html code for both javascript redirect and meta redirect
    			echo '<script type="text/javascript">window.location='.$website.'</script><noscript><meta http-equiv="refresh" content="0;url='.$website.'"></noscript>';		
    }
    
    PHP:
    something like that..
     
    n3r0x, Feb 14, 2010 IP
  3. Wasser

    Wasser Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    use a metarefresh. thats works best.
     
    Wasser, Feb 16, 2010 IP