phamenoth Posted May 22, 2007 Share Posted May 22, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/52413-need-to-create-custom-urls-not-subdirectories-for-users-upon-registration/ Share on other sites More sharing options...
textbox Posted May 22, 2007 Share Posted May 22, 2007 Does is really need to be www.user.site.com or can you accomodate www.site.com/user? Quote Link to comment https://forums.phpfreaks.com/topic/52413-need-to-create-custom-urls-not-subdirectories-for-users-upon-registration/#findComment-258667 Share on other sites More sharing options...
john010117 Posted May 22, 2007 Share Posted May 22, 2007 I think it's called mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/52413-need-to-create-custom-urls-not-subdirectories-for-users-upon-registration/#findComment-258680 Share on other sites More sharing options...
flappy_warbucks Posted May 22, 2007 Share Posted May 22, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/52413-need-to-create-custom-urls-not-subdirectories-for-users-upon-registration/#findComment-258685 Share on other sites More sharing options...
textbox Posted May 22, 2007 Share Posted May 22, 2007 Or you could use .htaccess and PHP_GET functions. See here A lot easier to do and implement. Quote Link to comment https://forums.phpfreaks.com/topic/52413-need-to-create-custom-urls-not-subdirectories-for-users-upon-registration/#findComment-258687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.