URLs like MySpace, without folders for each user?

Discussion in 'PHP' started by Arson, Sep 4, 2007.

  1. #1
    How would one go about using URL's like myspace does?

    What I mean: On myspace, You can type in the url, www.myspace.com/usernamehere, and It will take you to that username's profile.

    My question is, how do I do that, without making an actual folder for the user.

    Say I go to mysite.com/joe

    I want it to find the username "joe" in the database, and show the information for that user.

    So is there even a way to do that without actually creating a folder for each user? Id think there would be, or else that would mean MySpace has millions of folders on their servers...

    +Rep to helpers! Thanks in advance!
     
    Arson, Sep 4, 2007 IP
  2. craze3

    craze3 Well-Known Member

    Messages:
    454
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #2
    I was just about to post the same question! Thanks for bringing this up, I was having a hard time thinking of how to explain it :D
    Reason I ask is because PHPLD does the same thing w/ the categories but i doubt they do any htaccess modding or any server side editing stuff..hmmm
     
    craze3, Sep 4, 2007 IP
  3. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #3
    lol no problem.

    I was going to post earlier, but thought of a way I might be able to do it, unfortunately It didn't work...:(
     
    Arson, Sep 4, 2007 IP
  4. CriminalOrigins

    CriminalOrigins Peon

    Messages:
    276
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can use mod_rewrite to do this.

    Check out http://modrewrite.com, I'd recommend the forums there if you need help.
     
    CriminalOrigins, Sep 4, 2007 IP
    Arson likes this.
  5. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Thanks. Does anyone have a specific code or function that is made to do it though?
     
    Arson, Sep 4, 2007 IP
  6. loibeignacio

    loibeignacio Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yeah some htaccess / mod_rewrite stuffs ;)

    from:

    yoursite.com/users.php?user=loibeignacio

    to:

    yoursite.com/loibeignacio/ or yoursite.com/loibeignacio.html
     
    loibeignacio, Sep 5, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    
    RewriteEngine On
    RewriteRule ^([\w-]+)$ scriptname.php?username=$1
    
    Code (markup):
     
    nico_swd, Sep 5, 2007 IP