Possible Duplicate:
Create vanity URLs in a LAMP configuration
Once a user registers, I want the username they have chosen to be used to generate a unique profile page viewable to anyone (not just the user). If "bob" registers, he will have a profile at website.com/bob
I have looked at similar questions that say to solve the problem with .htaccess, but they don't describe how this can be done.
You wouldn't exactly need to generate a unique profile page upon registration. You can simply make a script like profile.php
which takes a parameter user
to dynamically show the profile of a given user by accessing /profile.php?user=bob
. Example:
<?php
$u = $_GET['user'];
echo "<h2>Profile of ".htmlentities($u)."</h2>";
?>
.htaccess comes into play when you want to rewrite the url website.com/user/bob
to point to website.com/profile.php?user=bob
by using the following, for example.
RewriteEngine On
RewriteBase /
RewriteRule ^/user/([0-9a-zA-Z]*)$ /profile.php?user=$1 [NC,QSA,L]