On Jan 12, 2011, at 4:56 PM, Bruno Rocha wrote:
> I am trying to configure a different way of routing, may be you can help me 
> or point some hint about it,
> It is a system where the user will register himself and get instant access to 
> an account (just like twitter), and the system will give a profile URL to the 
> user http://system.com/username and the actions needs to be as 
> http://system.com/username/controller/action.
> 
> I cant figure out how can I include the 'username' part.
> 

I got a little distracted by the 'how' and forgot to ask 'why'. Is this going 
to be used for login? Obviously you can't trust the username in the URL, so 
you'll have to authenticate, either by explicit login or cookie, right? I can 
see using it as a bookmark for quicker login, though Twitter appears to simply 
use a cookie: if I go to twitter.com, I'm recognized.

For the sake of this example, let's assume that your default a/c/f is 
init/default/index, as usual, and that your app is named 'init' (obviously you 
can change those names).

In the new router, if you have a function 
http://system.com/init/default/profile, then the outgoing URL 

        http://system.com/init/default/profile/username 

will be shortened to 

        http://system.com/profile/username

where username is request.args(0).

There's also something to be said for using the query string for username, 
since it accepts by default a broader range of characters:

        http://system.com/profile?Bruno
        http://system.com/profile?Brüñø
or rather
        http://system.com/profile?Br%C3%BC%C3%B1%C3%B8

Reply via email to