1

i'm building a site for my company, this site will be in some way like facebook or other social sites, and the user will have a public profile page. I can't find, or maybe i don't know where to look for, any information on how to do something to create that public page without creating a specific page for each user, i want to do something like facebook does when you type a username after the facebook url (EX. http://www.facebook.com/ANYUSERNAME) and then you fall into the profile page, somebody can help me with an idea? The development server is a windows 2008 using IIS 7.5 and PHP but the production server will be mandriva or any other linux distro with apache and php. Thnxs a lot to everyone in advance.

2 Answers2

1

dynamic URLs are done on most Unix/Linux based systems in Apache, by a plugin called 'mod_rewrite'. However, you are running windows. IIS has a rewrite plugin by Microsoft.

http://www.iis.net/download/URLRewrite

Essentially the behavior ends up being that you set up rules for specific folders or other things. If a page doesn't physically exist on disk, or doesn't end in .php, run the ruleset. if it matches the rule, pass it to a real page as a querystring or other variable to the codepage. If it doesn't exist, throw a 404.

Richthofen
  • 2,076
  • 19
  • 39
1

You'll need mod_rewrite (for IIS) and implement the front-controller pattern (usually in index.php).

The front-controller will then check the first segment of the URL (in your example it'll be ANYUSERNAME) and, if that route doesn't exist you can assume it's a user profile page. You can then choose to redirect the user to that specific profile page (something like /profile/USER), or just display it directly.

Community
  • 1
  • 1
Alix Axel
  • 151,645
  • 95
  • 393
  • 500