I am developing an application using zend framework. In the application I have to provide a URL for each user like mydomain.com/[username] then public will be able to view
Seems to me that the difficulty here is that you are using the same url scheme:
http:/example.com/something
to represent two types of actions:
This seems a bit odd to me. I'd prefer to put the user requests under a different url scheme, like:
http://example.com/user/bob
where standard routing rules can apply. Want to avoid the risk that a user registers with a name that conflicts with one of your static controllers. Of course, you could maintain a pool of "reserved" user names for your static controllers that would be unavailable for users to choose.
But if is really is the requirement that the same url format must be used for both types of requests, then I would do the following: route all requests to something like TrafficCopController
with an action directTrafficAction()
. The action could test - probably via db query - if the passed "something" parameter represents a real user. If so, then forward the request to controller=user, action=viewProfile
. Otherwise, forward the request to controller=something, action=index
.
See what I mean?