Redirect with variable entered into redirect url

 

Results 1 to 7 of 7
Php is something I know pretty much nothing about so I'm hoping someone can point ...
  1. #1
    Join Date
    Jun 2013
    Posts
    33
    Thanks
    3
    Thanked 8 Times in 8 Posts

    Default Redirect with variable entered into redirect url

    Php is something I know pretty much nothing about so I'm hoping someone can point me in the right direction. This may be something simple but my searches on google didn't turn up what I'm looking for. My guess I just don't know what to search for.

    What I'm looking to do is redirect from abc.cm/variable to cba.cm/blahblah"insert variable here"blahblah. So abc.cm/dogs would redirect to cba.cm/blahblahdogsblahblah.

    This would keep me from needing to create 1000s of redirects manually.




  2. #2
    bartosimpsonio's Avatar
    bartosimpsonio is offline U. B. Rich Soon
    Join Date
    Mar 2013
    Location
    Roaming BHW
    Posts
    4,575
    Thanks
    2,637
    Thanked 3,953 Times in 2,020 Posts

    Default Re: Redirect with variable entered into redirect url

    something like this...

    Code:
    $newString = "blabla" . $variable . "blabla";
    header("Location: /whatever?param=$newString");

  3. The Following User Says Thank You to bartosimpsonio For This Useful Post:

    just-buyin-stuff (12-17-2013)

  4. #3
    CosmicSoundz is offline Banned - see signature
    Join Date
    Apr 2012
    Posts
    1,235
    Thanks
    1,475
    Thanked 1,224 Times in 399 Posts

    Default Re: Redirect with variable entered into redirect url

    cant you just create a cname?

    edit.. never mind.. I overlooked "variable"
    This member has been permanently banned from BHW.

  5. #4
    Hecate is offline Newbies
    Join Date
    Jul 2013
    Posts
    42
    Thanks
    157
    Thanked 11 Times in 11 Posts

    Default Re: Redirect with variable entered into redirect url

    PHP can be a bit tricky, in that there are always multiple ways to do the same thing. Are you wanting to capture the entire URL, or just looking to pull out the GET variables with values? The easiest way, is just to make use of $_SERVER['QUERY_STRING']. It will give you everything posted after the domain and page, which includes all variables, values, and extraneous characters. However, if you aren't expecting to have anything more than 1 or 2 variables, then this should work out fine.

    Example URL: http://firstsite.com/index.php?referrer=timtebow
    <?php echo "<a href='http://secondsite.com/".$_SERVER['QUERY_STRING']."'>click here bitches!</a>"; ?>
    Which when followed,will take you to:
    http://secondsite.com/referrer=timtebow
    Before I forget, let me just say that allowing any form of unsanitized user input to be executed or otherwise carried out is a general no-no in programming. Something like this wouldn't result in a vulnerability any more dangerous than Cross Site Scripting, which can't be used for much else than social engineering... but just be wary of how this is implemented! No passing user credentials, or dates to secret meetings haha. Best of luck friend! And shoot me a message if you end up needing more help on this.
    Last edited by Hecate; 12-16-2013 at 08:50 PM.

  6. The Following User Says Thank You to Hecate For This Useful Post:

    just-buyin-stuff (12-17-2013)

  7. #5
    Join Date
    Jun 2013
    Posts
    33
    Thanks
    3
    Thanked 8 Times in 8 Posts

    Default Re: Redirect with variable entered into redirect url

    Code:
    <?php echo  
    
    header("Location: hxxp://secondsite.cm/".$_SERVER['QUERY_STRING']."");?>
    That seems to be working like I was hoping for. I figured it was so simple it was stupid for anyone that knew php at all. Thanks guys.

    Incase anyone is wondering what this is for it's for sending traffic directly to the item shown without showing my affiliate link.
    So instead of amazon.cm/linkcodeobviouslytryingtomakemoney/dogchewtoy/idcode=12345

    I can post a link to mysite.cm/?dogchewtoy someplace and they get redirected to the amazon link code with the product name entered in it. I'm not really using amazon btw it's just an example. All the links will be on my site so no I'm not planning on spamming fb or anything lol. This is just a huge time saver so I don't have to make a ton of redirects by hand.

  8. #6
    abda53 is offline Newbies
    Join Date
    May 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Redirect with variable entered into redirect url

    Make sure you put an exit; after your header redirect. You might also want to put your redirects inside your .htaccess

  9. #7
    funque is offline Newbies
    Join Date
    Dec 2013
    Posts
    21
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Redirect with variable entered into redirect url

    Quote Originally Posted by just-buyin-stuff View Post
    Incase anyone is wondering what this is for it's for sending traffic directly to the item shown without showing my affiliate link.
    So instead of amazon.cm/linkcodeobviouslytryingtomakemoney/dogchewtoy/idcode=12345
    It depends of your partner website - when you send traffic to affiliate link, website can set cookie and forward user to clean URL without affiliate ID. You can't change these things - sorry!


Similar Threads

  1. Replies: 4
    Last Post: 10-11-2012, 03:07 PM
  2. Replies: 4
    Last Post: 07-24-2012, 01:58 PM
  3. catchall redirect domain that shows original url entered?
    By beer30 in forum HTML & JavaScript
    Replies: 1
    Last Post: 09-01-2010, 12:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




BlackHatWorld on Twitter BlackHatWorld on FaceBook


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108