Jump to content

Need to create custom URLs (not subdirectories) for users upon registration


Recommended Posts

Hi folks,

 

I'd like to give a user who registers on my site a custom URL. This would not be a physical folder, but rather a subdomain that points to a different page. Think of a myspace URL, as an example. So, upon registering I'd dumb down the username in case there are any non alphanumeric characters, and save it in the db as a field. I'd then use savedusername.website.com for the redirect.

 

I have (basic) experience using mod_rewrite, but I'm not sure if that's the best solution. I'm wondering if anyone has created something like this, and knows:

 

1. Is mod_rewrite the best way to go? If so, would I really have to have thousands of lines, each line for a different username and their URL?

 

2. Is there a better PHP/DB way to go that doesn't involve creating a linking file that has thousands of redirect lines in it?

 

Thanks :)

personally as a user i prefer www.site.com/user

 

as opposed to: www.user.site.com

 

i spose its a preference thing....

 

but for anyone that reading that wants to do such a thing (i.e. www.site.com/user)

 

then for reference what i done was:

 

create a dir with the username so for the slightly slow people that here is an example:

 

user would be for example: test

 

the program would create a folder called test (look on php.net on how to make folders)(make sure u make u don't have duplicate usernames)

 

inside that folder you create a file called index.php (or whatever your server is defaulted to) and make several references to your database inc file, your header, and footer files and and dependes you have that toy need... followed by any strings thats needed for the database to fetch the user data...

 

then you echo that stuff out init...

 

to do sub-domains you have to get involved with the server and that's a whole different kettle of fish...  just be simple and easy!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.