I want to what this thing is called :D :D :D

Discussion in 'Programming' started by kapeel_sable, Oct 3, 2009.

  1. #1
    Hi guys,

    I am really baffled with this thing as I want to develop something using this , but i don't even know what this technology/technique(whatever you say) is called.It is related to .htaccess .

    Like ,
    http://shrinkthislink.com
    provide URL shrinking ( everybody here must know this)
    they provide something like this,

    http://urlm.in/dbgq

    So, they are not of course making a folder for every new link and then putting an index.html ( or anything .php , .asp ;) ) in it .
    I am sure they are using .htaccess for this. I want to learn about this and most importantly what this thing is called.

    So please tell me the name and give a link to it. Your help will be greatly appreciated. :)
     
    kapeel_sable, Oct 3, 2009 IP
  2. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #2
    I looks like URL shortening and you can do it easily with Apache + URLRewriting + PHP + MySQL.

    You have to store the sequence and the URL it represents into a database.

    http://urlm.in/dbgq
    http://urlm.in/dbga
    http://urlm.in/dbgb -> http://blog.caranddriver.com/freshened-hyundai-santa-fe-bows-in-frankfurt/
    http://urlm.in/[B]ddat[/B] -> http://www.drk.com.ar/docs/photos/villa-de-merlo-san-luis-argentina.php

    URL rewriting will probably convert

    http://urlm.in/ddat -> http://urlm.in/index.php?id=ddat

    Then index.php would look up database for ddat ID and redirect you to http://www.drk.com.ar/docs/photos/villa-de-merlo-san-luis-argentina.php
     
    caprichoso, Oct 3, 2009 IP
  3. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #3
    An easy way you can do it with just PHP is, you have PHP get the url of the self page, say it is "http://urlm.in/dbgq" in full. Then, strip out http://urlm.in/ and http://www.urlm.in/ always, and you are left with dbgq, which you could send into a database and pull the url. Make sure you remove all special characters, so nobody can do any sql injection.

    I did this with a site once, except with numbers

    site.com/81
    site.com/517

    And it worked fine, with just php. so it is possible.
     
    crath, Oct 3, 2009 IP