Jump to content

Giving Profile link a personal url


cmgmyr

Recommended Posts

[!--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.
[!--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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.