url redirect ($20 paypal to the best solution)

Discussion in 'Programming' started by furious, Nov 22, 2009.

  1. #1
    i want this url http://www.vids.net/index.php?ref=somedomain.com redirect to http://www.vids.net

    the index page is coded in php and smarty.

    i have a visitor tracker in header so it must redirect before it reachs it to avoid double hits counting.

    i suspect this would be best done through .htaccess but also doable through php. any ideas?

    whoever post the best solution first will receive 20 bucks paypal. not much but enough for some motivation to respond :)

    thanks
     
    furious, Nov 22, 2009 IP
  2. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #2
    so you must use htaccess for preventing this, or must use PHP before tracker intiate, with htaccess:

     
    temp2, Nov 22, 2009 IP
  3. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #3
    i included the code in htaccess but still dont work

    Options -Indexes

    RewriteEngine on

    RewriteRule ^index.php?ref=([\S\W]*) / [L,R=301]

    <IfModule mod_security.c>

    SecFilterEngine Off

    SecFilterScanPOST Off

    </IfModule>
     
    furious, Nov 22, 2009 IP
  4. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #4
    <? if ($_GET['ref']) {
    Header("Location: http://www.vids.net/");
    }
    ?>

    i tried this but i get the error

    Fatal error: Smarty error: [in smarttubedotcom-dark/header.tpl line 7]: syntax error: unrecognized tag: Header("Location: http://www.vids.net/"); (Smarty_Compiler.class.php, line 455) in /home/user/vids/vids.net/stp/admin/classes/smarty/Smarty.class.php on line 1092
     
    furious, Nov 22, 2009 IP
  5. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Just put this before the counter:
    <?php header("location:http://yoursite.com/"); ?>
    PHP:
    That should work. ;)

    EDIT: I saw your reply, lol. Let me think, keep refreshing. :)
    Let me see your code, PM me it. :)
     
    D-Fraz, Nov 22, 2009 IP
  6. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #6
    template contain of multiple files so i've PMed you the header.tpl
     
    furious, Nov 22, 2009 IP
  7. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #7
    quite weird that .htaccess doesnt work..
     
    furious, Nov 22, 2009 IP
  8. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    I sent you a PM, and noticed I was wrong.
    Move that line of PHP to the very top of the header page.
    Header's cannot be after HTML.
     
    D-Fraz, Nov 22, 2009 IP
  9. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #9
    <head><?php header("location:vids.net"); ?>

    still nothing
     
    furious, Nov 22, 2009 IP
  10. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    Before the head tag.
    I mean literally at the very first line.
     
    D-Fraz, Nov 22, 2009 IP
  11. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #11
    done. but no good.

    {if $smarty.request.view == 'my_profile' or $smarty.request.vi

    i removed it cause the error was messing the page. error above was on the top of the page.
     
    furious, Nov 22, 2009 IP
  12. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    Place <?php header("location:http://www.site.com/"); ?> on the top of the page.
    I'm talking about the top of the whole page you are viewing, before anything else.
    There isn't a reason for that not to work.

    Thanks.
    EDIT; Your file extension is .php right?
     
    D-Fraz, Nov 22, 2009 IP
  13. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #13
    hi.

    the code is now at the very top of the page.

    the output file is index.php but its decoded with ioncube so i cant view the source.

    templates are .tpl
     
    furious, Nov 22, 2009 IP
  14. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14
    I'm not sure at all, then.
    I'm sorry man. :(
     
    D-Fraz, Nov 22, 2009 IP
  15. pixmania

    pixmania Peon

    Messages:
    229
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
    Paste the following into header.tpl for testing, then try index.tpl assuming you have one ?
    
    {literal}
    <script type="text/javascript">
    <!--
    window.location = "http://www.vids.net"
    //-->
    </script>
    {/literal}
    
    Code (markup):
     
    pixmania, Nov 23, 2009 IP
  16. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #16
    tried. blank page which keep loading..
     
    furious, Nov 23, 2009 IP
  17. furious

    furious Well-Known Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    151
    As Seller:
    100% - 0
    As Buyer:
    100% - 10
    #17
    im increasing the award to 30 bucks paypal.
     
    furious, Nov 23, 2009 IP
  18. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #18
    You need to have <?php header("location:xxxxxxxxxx.com"); ?> on the very very very top of the page.
    On top of the template, anything. As long as that's what it gets first when the page is opened.
    I'm sure it will work.
     
    D-Fraz, Nov 23, 2009 IP
  19. pixmania

    pixmania Peon

    Messages:
    229
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #19
    Thats ok it was just a test...

    Heres the code you need, it will only redirect if the url has a ref in it.

    
    {literal}
    {php}
    if (isset($_GET['ref'])) {
    echo "<script>window.location.replace(\"http://www.vids.net\")</script>";
    }
    {/php}
    {/literal}
    
    Code (markup):
     
    Last edited: Nov 23, 2009
    pixmania, Nov 23, 2009 IP
  20. roezer

    roezer Active Member

    Messages:
    227
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    50
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #20
    try this in the /public_html/.htaccess
    ErrorDocument 404 /
    
    RewriteEngine On
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(.*) /archive/1/$1/$2/$3/$4
    RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2}) /archive/1/$1/$2/$3
    RewriteRule ^([0-9]{4})/([0-9]{1,2}) /archive/1/$1/$2
    
    Code (markup):
    It works for me
     
    roezer, Nov 23, 2009 IP