javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CPA-Rush
    small trip to underworld
    • Mar 2012
    • 4927

    #1

    javascript

    i need to redirect based on referrer

    for example

    #if source www.site.com/folder/0123 >> go link1

    or
    ##if source www.site.com/folder/4567 >> go link 2

    or
    ##if source www.site.com/folder/89xx >> go link3

    else , in case the user doesn?t sent his referrer or come from any other source >> just go link4

    PS: my current redirect script is .js file not inside html file

    thanks

    automatic exchange - paxum , bitcoin,pm, payza

    . daizzzy signbucks caution will black-hat black-hat your traffic

    ignored forever :zuzana designs
  • Tdash
    Confirmed User
    • May 2013
    • 749

    #2
    Javascript? It can easily be done in php.
    71% of America's GDP emanates from Democrat counties.

    Comment

    • CPA-Rush
      small trip to underworld
      • Mar 2012
      • 4927

      #3
      the reason i prefer javascript because i will be able to see stats via analytic

      php execute faster than anything else

      automatic exchange - paxum , bitcoin,pm, payza

      . daizzzy signbucks caution will black-hat black-hat your traffic

      ignored forever :zuzana designs

      Comment

      • sarettah
        see you later, I'm gone
        • Oct 2002
        • 14293

        #4
        Simple version:

        <script type="text/javascript">

        if(document.referrer=='http://www.site.com/folder/0123')
        {
        window.location='http://whatever_url_1.com ';
        }
        else if(document.referrer=='http://www.site.com/folder/4567')
        {
        window.location='http://whatever_url_2.com ';
        }
        else if(document.referrer=='http://www.site.com/folder/89xx')
        {
        window.location='http://whatever_url_3.com ';
        }
        else
        {
        window.location='http://whatever_url_4.com ';
        }

        </script>
        All cookies cleared!

        Comment

        • CPA-Rush
          small trip to underworld
          • Mar 2012
          • 4927

          #5
          thanks sarettah i will try this code +1

          automatic exchange - paxum , bitcoin,pm, payza

          . daizzzy signbucks caution will black-hat black-hat your traffic

          ignored forever :zuzana designs

          Comment

          • CPA-Rush
            small trip to underworld
            • Mar 2012
            • 4927

            #6
            sarettah this worked with me just after doing little change


            Code:
            if (document.referrer.indexOf('http://gfy.com/') > -1)
                {
                 window.location='http://yahoo.com';
            }
            else if (document.referrer.indexOf('http://gfy.com/forum') > -1)
                {
                 window.location='http://msn.com';
            }
            else 
              {
                 window.location='http://www.google.com';
            }



            thanks

            Browsers do not always provide a document.referrer. If the referrer is from a https it is blocked, or if the security settings in the broswer block it none is provided. These people will never get past the page and will be cut off from being able to use your site
            they will go to http://www.google.com , right ?

            automatic exchange - paxum , bitcoin,pm, payza

            . daizzzy signbucks caution will black-hat black-hat your traffic

            ignored forever :zuzana designs

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14293

              #7
              Originally posted by rosx
              sarettah this worked with me just after doing little change


              Code:
              if (document.referrer.indexOf('http://gfy.com/') > -1)
                  {
                   window.location='http://yahoo.com';
              }
              else if (document.referrer.indexOf('http://gfy.com/forum') > -1)
                  {
                   window.location='http://msn.com';
              }
              else 
                {
                   window.location='http://www.google.com';
              }
              Well, it appears to me that you will never send anyone to msn.com with that.

              Your first condition document.referrer.indexOf('http://gfy.com/') > -1 should send anyone from gfy to yahoo. Since the second condition also includes the first condition it will never be hit.

              So, if you wanted to do that switch condition 1 and 2 around. Make condition 1 be gfy.com/forum and condition 2 be just gfy. That way the ones to the forums will be redirected to msn and then anyone else from gfy will be redirected to yahoo.

              I had done the exact match conditions because you had included specific pages in your example. As I said, it was a very simple version.

              Glad it worked for you.

              .
              All cookies cleared!

              Comment

              • CPA-Rush
                small trip to underworld
                • Mar 2012
                • 4927

                #8
                Originally posted by sarettah
                Well, it appears to me that you will never send anyone to msn.com with that.

                Your first condition document.referrer.indexOf('http://gfy.com/') > -1 should send anyone from gfy to yahoo. Since the second condition also includes the first condition it will never be hit.

                So, if you wanted to do that switch condition 1 and 2 around. Make condition 1 be gfy.com/forum and condition 2 be just gfy. That way the ones to the forums will be redirected to msn and then anyone else from gfy will be redirected to yahoo.

                I had done the exact match conditions because you had included specific pages in your example. As I said, it was a very simple version.

                Glad it worked for you.

                .


                i will correct that and remove that switch " > -1)"

                tnx for the heads up , cheers
                Last edited by CPA-Rush; 04-16-2014, 06:18 AM.

                automatic exchange - paxum , bitcoin,pm, payza

                . daizzzy signbucks caution will black-hat black-hat your traffic

                ignored forever :zuzana designs

                Comment

                • Kafka
                  Confirmed User
                  • Oct 2002
                  • 466

                  #9
                  I suggest you should use ModRewrite (htaccess) with that.

                  Comment

                  • CPA-Rush
                    small trip to underworld
                    • Mar 2012
                    • 4927

                    #10
                    Originally posted by Kafka
                    I suggest you should use ModRewrite (htaccess) with that.
                    i need to keep the analytics stats

                    automatic exchange - paxum , bitcoin,pm, payza

                    . daizzzy signbucks caution will black-hat black-hat your traffic

                    ignored forever :zuzana designs

                    Comment

                    Working...