how to hide the actual url

Discussion in 'PHP' started by abdo629, Aug 23, 2011.

  1. #1
    hi

    i am php beginner

    i want to hide actual url links of my site

    from the mysql i get the url like http://www.megaupload.com/?d=1DYRLC0D

    and my link become http://s7s7.org/p/?http://www.megaupload.com/?d=1DYRLC0D

    i want the link to be http://s7s7.org/p/?546345rtsfsd34534wwfsdfdfdf

    or any thing like that

    i know i explain my request very bad but hope you understand me

    this is the code of the page

     
    Last edited: Aug 23, 2011
    abdo629, Aug 23, 2011 IP
  2. [GotHost] James

    [GotHost] James Guest

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'd have to store a unique ID for each URL in the DB. Then when someone passes an ID (e.g. ?d=2399a9sd9a94939f, use _GET['d']), fetch the correct URL from the DB and 302 redirect to it (like so: header("Location: THE_URL")).

    Alternatively, instead of storing the ID you could encode the original URL somehow I guess.
     
    [GotHost] James, Aug 23, 2011 IP
  3. abdo629

    abdo629 Greenhorn

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    thanks for replay

    i want to know how to encode the original url
     
    abdo629, Aug 23, 2011 IP
  4. abdo629

    abdo629 Greenhorn

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    thanks for replay

    i want to know how to encode the original url
     
    abdo629, Aug 23, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    echo "document.write('<a href=\"$the_url_you_want_the_link_to_go_to\" target=\"_blank\">$the_url_you_want_the_user_to_see</a>';
    Code (markup):
     
    Rukbat, Aug 23, 2011 IP
  6. Technoslab

    Technoslab Peon

    Messages:
    46
    Likes Received:
    3
    Best Answers:
    3
    Trophy Points:
    0
    #6
    The idea of using $_GET['id'] is much better in such cases but here's an encoded URL method.

    
    $mulink = 'http://www.megaupload.com/?d=1DYRLC0D';
    $encoded = base64_encode($mulink);
    echo "<a href='?link=$encoded'>Download</a>";
    
    Code (markup):

    and on download page.

    
    $mulink = $_GET['link'];
    $decoded = base64_decode($mulink);
    header("Location: $decode");
    exit;
    
    Code (markup):

    Don't forget to put validation checks at proper places.
     
    Technoslab, Aug 23, 2011 IP