Jump to content


Not sure what this is called...


7 replies to this topic

#1 pizzaboy9010

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 03 March 2006 - 12:11 AM

But I would love to learn how to do this.

Say that my site is www.mysite.com. When users go to, say, www.mysite.com/username, it goes to there profile, similar to how Xanga does it.

Any tips or the code on how to do this would be greatly appreciated.

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 03 March 2006 - 03:41 AM

i think you mean Mod_Rewrite, have a search around the forum, there are lots of questions on it atm, and also there is some good tutorials in the database.

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 March 2006 - 04:10 PM

You would use mod rewrite to change that path, to a server/php friendly one that uses a query string. The use the $_GET variable to get the name out of the url, select the name from your database, and go from there.

#4 Pooch

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 05 March 2006 - 02:19 PM

Another way of doing it would be to just create a folder for each user and have an index.php file within the folder, so when you go to yoursite.com/username the contents of index.php will be displayed.

#5 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 05 March 2006 - 03:12 PM

Quote

Another way of doing it would be to just create a folder for each user and have an index.php file within the folder, so when you go to yoursite.com/username the contents of index.php will be displayed.


that would just make things more messy, long time to set up and when it comes to updating it, you would have to do it multiple times, and i leant that the hard way myself.

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 05 March 2006 - 03:12 PM

Coordinating between the possibly thousands of user folders, and a database that holds the user info would simply over complicate things. Through .htaccess its as simple as 2 short steps.

But, if .htaccess is unavailable for some reason, your way would be the only alternative i can think of if he want's to keep the clean url. Personally, i'd scrap the clean url if i had to make a folder for every user.

#7 Pooch

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 05 March 2006 - 09:18 PM

My bad, I setup a site with an individual folder for each user. It kind of made more sense because when a user joins they're given certain files within their directory that they can edit. It was annoying making a function to create the dirs and to remove/clear the dirs. I'll try the .htaccess way.

#8 pizzaboy9010

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 06 March 2006 - 01:02 AM

Thanks! Mod Rewrite works great!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users