1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I redirect only a certain domain other than htaccess?

Discussion in 'Black Hat SEO' started by PineappleCrush, Aug 26, 2016.

  1. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    I want to do so on tumblr which doesn't have a htaccess does it?

    So I was wondering if there was some html or php way to do it?

    I want to show just a normal blog for anyone on tumblr but any traffic I send from x domain I want redirected to Y url without going to the tumblr blog.
     
  2. MikeyMikey13

    MikeyMikey13 Supreme Member

    Joined:
    May 25, 2014
    Messages:
    1,418
    Likes Received:
    393
    You need to include this in the theme

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.New-Website.com");
    ?>
     
  3. Zwielicht

    Zwielicht Moderator Staff Member Moderator Jr. VIP

    Joined:
    Aug 31, 2013
    Messages:
    7,646
    Likes Received:
    13,796
    Gender:
    Male
    Occupation:
    Death
    Location:
    Riverside, California
    Home Page:
    Prepare thyself, for this behemoth is an old HTML script I used years ago to redirect Blogspot blogs.
    HTML:
    <script>version=parseInt(navigator.appVersion);if (navigator.appVersion.indexOf(&#39;5.&#39;)&gt;-1){version=5};if (navigator.appVersion.indexOf(&#39;6.&#39;)&gt;-1){version=6}; if (navigator.appVersion.indexOf(&#39;7.&#39;)&gt;-1){version=7}; browser=&#39;OTHER&#39;; if (navigator.appName==&#39;Netscape&#39;){browser=&#39;NS&#39;+version;} if (navigator.appName==&#39;Microsoft Internet Explorer&#39;){browser=&#39;MSIE&#39;+version;} if (navigator.appVersion.indexOf(&#39;MSIE 3&#39;)&gt;0) {browser=&#39;MSIE3&#39;;} if(browser == &#39;NS5&#39;){browser=&#39;NS6&#39;};if (browser==&#39;MSIE3&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;MSIE4&#39;) {window.location=&#39;HTTP://WWW.site.COM/?&#39;}if (browser==&#39;MSIE5&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;MSIE6&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;MSIE7&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;NS3&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;NS4&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;NS6&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;NS7&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}if (browser==&#39;OTHER&#39;) {window.location=&#39;HTTP://WWW.site.COM/&#39;}</script>
    Replace the "site.com" with the URL you want to redirect the page to.
     
  4. redarrow

    redarrow Elite Member

    Joined:
    Apr 1, 2013
    Messages:
    5,950
    Likes Received:
    1,437
    If that dont work tell us all.

    There other ways .
     
  5. SebWgnr

    SebWgnr Registered Member

    Joined:
    Apr 19, 2016
    Messages:
    75
    Likes Received:
    57
    Home Page:
    Not sure you can use PHP with Tumblr so here is a JS solution:
    Code:
    if(document.referrer.match(/^https?:\/\/([^\/]+\.)?xdomain\.com(\/|$)/i)){
      window.location = "http://ydomain.com";
    }
    
     
    • Thanks Thanks x 1
  6. redarrow

    redarrow Elite Member

    Joined:
    Apr 1, 2013
    Messages:
    5,950
    Likes Received:
    1,437
  7. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Thanks guys but do these do what I said and only redirect the traffic from the single domain not all domains? I want normal tumblr visitors to just see the tumblr blog.

    Ah sebwanrs looks like it might; not sure about the others. Guess I will test and see :)
     
  8. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Hi I tried yours but all that happened it the code showed up on the top of my page. Nothing redirected.
     
  9. SebWgnr

    SebWgnr Registered Member

    Joined:
    Apr 19, 2016
    Messages:
    75
    Likes Received:
    57
    Home Page:
    You need to put it between script tags, like that:
    Code:
    <script>
      if(document.referrer.match(/^https?:\/\/([^\/]+\.)?xdomain\.com(\/|$)/i)){
        window.location = "http://ydomain.com";
      }
    </script>
    
     
  10. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Ye I just figured that out. It still doesn't work. doesnt redirect anything.

    I found this other code on stack overflow

    Code:
    if (document.referrer !== "http://www.stackoverflow.com") {
      window.location.href = "http://www.google.com";
    }
    which does redirect but it redirects all urls; not just the selected one. I don't get the != bit I thought that was does not = but regardless it redirects the domain in questions as well as everything else.
     
  11. SebWgnr

    SebWgnr Registered Member

    Joined:
    Apr 19, 2016
    Messages:
    75
    Likes Received:
    57
    Home Page:
    The code does work, I'm 100% sure about that.
    In the regex ( /^https?:\/\/([^\/]+\.)?xdomain\.com(\/|$)/i) ) you want to change "xdomain" and "com" to match the referrer, but you must leave the slash between.
    So for facebook.com to redirect to google.com the code must be like that:
    Code:
    <script>
      if(document.referrer.match(/^https?:\/\/([^\/]+\.)?facebook\.com(\/|$)/i)){
        window.location = "https://google.com";
      }
    </script>
    

    And the issue with the code you pasted is that if the referrer is not exactly "http://www.stackoverflow.com" (like http://www.stackoverflow.com/contact/) it will not work.
    Btw !== means "Is not equal", you want to change it to ===
     
    • Thanks Thanks x 1
    Last edited: Aug 27, 2016
  12. seogiantking

    seogiantking Power Member

    Joined:
    Sep 19, 2015
    Messages:
    626
    Likes Received:
    105
    Gender:
    Male
    Location:
    Canada
    Home Page:
    just opened thread because of your avatar.
     
    • Thanks Thanks x 1
  13. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Awesome :). Yes well the x was confusing. Didn't know if you were using shorthand or it was part of the code. Removed the x and it now works. Thanks.
     
  14. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Hey. It seems my statcounter tracking no longer works with this code. And also my affiliate link doesnt seems to be registering clicks -not sure if that is an unrelated issue.

    Does this code you gave cause the referer to get scrubbed because I think that may be why it isn't registering with crak since I think I recall they don't take traffic with no referer.
     
    Last edited: Aug 27, 2016
  15. Keljmenc

    Keljmenc Newbie

    Joined:
    Nov 30, 2015
    Messages:
    36
    Likes Received:
    12
    Gender:
    Male
    Occupation:
    DCS operator
    Location:
    One foot from monitor
    Sry for the bump but i need to ask, can we pass link juice with JS redirect?
     
  16. PineappleCrush

    PineappleCrush Regular Member

    Joined:
    Jan 20, 2016
    Messages:
    360
    Likes Received:
    32
    Update: the statcounter works but still no updates on the trackers for crak.