tags:

views:

36

answers:

3

http://twitter.com/codinghorror
http://twitter.com/login

These both look like twitter accounts but the second one is not. It's a system page.

How does twitter in this case know that logout is not a username and how can it make sure that no user registers under a system page name that exist or that may come into existance in future?

A: 

Good question? My guess is that twitter has special logic that checks the username (check for special words) and utilizes URL rewriting and routing accordingly. I'd be curious to see a snippet of the code though :)

D0cNet
That doesn't answer the question about how they know in advance what new special words will be.
Oddthinking
+2  A: 

In most url routing frameworks there is a precedence order for your routing rules. Usually fist come first serve, so that the first url patten that matches controls the url.

In this case lets say twitter had to routes defined

map.connect 'login', :controller => 'auth', :action => 'login'
map.connect ':username', :controller => 'user', :action => 'show'

The first route would match the url twitter.com/login , but when you type in twitter.com/coddinghorror it would fail to match the first route and then match the second.

Matthew Manela
+1  A: 

They cannot know in advance. What development they will be doing years ahead. But of curse the could reserve words for trends, current and coming projects - just in case.

The login/logout part is easily achieved by rewriting/routing the url

/login/ - go to login code
/([a-z]+?)/ - go to user page appending $1
Michael