This and the next recipes in this chapter deal with the new parameter-based router, which is generally easier to configure, and handles most common re-writing tasks effectively. If possible, try to use the parameter-based router, but if you need more control for special URL-rewriting tasks, look at the pattern-based router.
The starting point for using the parameter-based router is to copy the file router.example.py
to routes.py
, in the web2py base
directory. (The file routes.example.py
serves the same purpose for the pattern-based router.) The example
file contains basic documentation for its respective routing systems; additional documentation is available online in the web2py book, Chapter 4, The Core: URL rewrite and Routes on error..
Whenever routes.py
is changed, you must either restart web2py or, if the admin app is available, load the following URL, for the new configuration to take effect:
http://yourdomain.com/admin/default/reload_routes