I need some help on creating a user profile system. I want it to be like Facebook or Myspace where it has only the username after the address, no question marks or anything, for example, www.mysite.com/username
. I have all the register, logging scripts, etc. all done, but how do I go to profiles using the URL example above, "/username"?
You would need to create a mod rewrite that took the first directory and passed it as a $_GET parameter.
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)/$ index.php?user=$1
That should rewrite anything after '/' as index.php?user=directory