cmgmyr Posted May 9, 2006 Share Posted May 9, 2006 You know how myspace let's you pic your own url? (myspace.com/myname)How do I impliment that on my own site.I currently have the profiles set up as profile.php?userid=usernumber Quote Link to comment Share on other sites More sharing options...
rt-box Posted May 9, 2006 Share Posted May 9, 2006 [!--quoteo(post=372570:date=May 9 2006, 03:15 PM:name=cmgmyr)--][div class=\'quotetop\']QUOTE(cmgmyr @ May 9 2006, 03:15 PM) [snapback]372570[/snapback][/div][div class=\'quotemain\'][!--quotec--]You know how myspace let's you pic your own url? (myspace.com/myname)How do I impliment that on my own site.I currently have the profiles set up as profile.php?userid=usernumber[/quote]You need to have mod_rewrite enabled in Apache and configure it so that when www.example.com/myname is called, it loads profile.php?username=myname.In that case your users must have unique usernames.You can refer to [a href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html\" target=\"_blank\"]the Apache website[/a] for mod_rewrite documentation. It's fairly straightforward. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted May 9, 2006 Author Share Posted May 9, 2006 Cool. Thanks! I will check it out. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted May 9, 2006 Author Share Posted May 9, 2006 Another question...How do I make this dynamic to where they have a little text box and they type in the name they want, and after it is verified, then it goes and makes the redirect? Quote Link to comment Share on other sites More sharing options...
rt-box Posted May 9, 2006 Share Posted May 9, 2006 [!--quoteo(post=372595:date=May 9 2006, 04:01 PM:name=cmgmyr)--][div class=\'quotetop\']QUOTE(cmgmyr @ May 9 2006, 04:01 PM) [snapback]372595[/snapback][/div][div class=\'quotemain\'][!--quotec--]Another question...How do I make this dynamic to where they have a little text box and they type in the name they want, and after it is verified, then it goes and makes the redirect?[/quote]You only need to figure out a generic RewriteRule so that all URLs matching <http://www.example.com/anyname> (and only those URLs) will point to [a href=\"http://www.example.com/profile.php?username=anyname\" target=\"_blank\"]http://www.example.com/profile.php?username=anyname[/a]. As the documentation shows, you just have to figure out what's the regexp for that.Once you have done that, when a user registers, you just need to check whether they want an existing username, and register it normally. Since the redirect will work for any name, there's nothing else to do on that side. You also have to change your profile.php page so that if someone comes to [a href=\"http://www.example.com/unknown_username\" target=\"_blank\"]http://www.example.com/unknown_username[/a], the profile.php either throws a 404 page, or nicely tells the client that he probably misspelled the name. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted May 9, 2006 Author Share Posted May 9, 2006 ok thanks again! Quote Link to comment 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.