|
Posted by Rik on 05/23/06 01:41
todd@elygenhosting.com wrote:
> Im not too sure how to go about this. I am working on a project where
> i have users register on the site and when they do they need to be
> assigned a url like this http://www.thesite.com/username. Kind of like
> it is on myspace. I was thinking
> 1) using a php script to have cpanel create a subdomain for each user.
> 2) when the user registerd have a folder created somewhere then have
> some code in a 401
> page that searches the database for the /username at the end of the
> url then
> direct to the correct rfolder/page.
Could be done, but might be a hassle.I like rewriterules of apache:
If your users don't upload html but just assign them urls like
http://www.thesite.com/~username, and put a .htaccess file in the webroot:
..htacess:
RewriteEngine On
RewriteRule ^~(.*)$ users.php?user=$1
Where users.php is a file that creates a page with the content deliverd by
users, extracted from a databse for example. The ~ is used to be able to
tell wether the request is somewhere to your own site, or to a userpage. You
could dome up with another way to distinguish them offcourse.
If your users DO upload html, why not just mkdir(username), and tell them to
don't forget the last '/' in http://www.thesite.com/username/ ?
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|