username urls like twitter and facebook

为君一笑 提交于 2019-11-30 16:16:56

问题


how does twitter and facebook etc. make unique url eg. twitter.com/billgates

if i would like to do the same (give my users unique urls with username), is it a application or do you crate a directory for each user with a index page??

by the way im using coldfusion.

thanks


回答1:


More generally these online services (Facebook, Twitter, any site that stores a username) use a database and tests for so see if the username is unique at the time of creation. Usually by querying the name before allowing the new account to be created (many do this with ajax requests as the user enters the name in the signup form).

Once the account is created then the server can be set up to handle the path name (using something like mod_rewrite) when a URL request is received, and pass along the information to a script that then accesses that user's information in the database and renders the page.

This blogpost & video seem to be pretty helpful but since I'm not sure what your setup is it should at least point you in the right direction... Also Coldfusion scares me.




回答2:


There wouldn't be an actual directory. Typically, these apps use mod_rewrite or equivalent to map the URLs.




回答3:


I'm not that familiar with CF, but the way Facebook does it (in affect) is have an Apache rewrite rule that redirects pages that match /text3423 to /profile.php?username=text3423 (not really, but that's the basic implementation.)

Twitter uses the routing of Ruby on Rails, so really, there are no actually directories at all. It just maps /* to their user feed page.




回答4:


You can't use like that in Coldfusion anyway but you can use like http://cftwitter.com/index.cfm/username/billgates.

Fortunately, SEO feature is supported in IIS7. You can try and test.



来源:https://stackoverflow.com/questions/3129939/username-urls-like-twitter-and-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!