On Feb 19, 2011, at 3:53 PM, Ross Peoples wrote:
> I am trying to develop a WordPress-like application with web2py and now I'm
> thinking about URL structures. WordPress lets you select what kind of
> permalink structure you want to use. With my application, I would like to
> have pages mapped like this:
> http://domain.com/the-page
>
> I have played with routes.py a little bit, but I can't seem to get it to work
> right. Anyone know how I can accomplish this? I have tried doing this in
> routes.py, but using the URL given above, I get an Invalid Request:
>
> routes_in = (
> ('/', '/myapp/default/index'),
> )
>
> routes_out = (
> ('/myapp/default/index', '/'),
> )
You need something like this:
routes_in = (
('/$anything', 'myapp/default/page/$anything'),
)
...where pages is a function in the default controller. However, that prevents
access to any other controller/function, so you need to catch any exceptions to
this general rule first.
In your example above, the path /the-page doesn't match anything in routes_in,
so web2py figures it must be an application name.