Introduction
Web2py is a Python-based, accessible, and open-source web framework enabling agile development of database-driven online applications. It is a full-stack framework that includes all the elements a developer needs to create a fully functional web application.

Web2py can rewrite the URL path of incoming requests before running the controller action (URL mapping), and it can also rewrite the URL path generated by the URL function (reverse URL mapping).
Let’s learn how to rewrite URLs in web2py.
URL Rewrite Systems in Web2py
Web2py contains two different URL rewrite systems: a simple parameter-based system for most use cases and a flexible pattern-based system for more complicated applications. Create a new file named routes.py in the “web2py” folder to provide the URL rewriting rules (the contents of routes.py will depend on which of the two rewrite systems you choose). Both systems must be used separately.
Note: If you make changes to routes.py, you must reload it. There are two methods to accomplish this: either restart the web server or click the Routes Reload option in the admin. Routes will not reload if they contain a bug.
Let’s learn about these URL rewrite systems.
Parameter-Based System
The parameter-based (parametric) router allows quick access to numerous "canned" URL-rewrite techniques. Its capabilities include the following:-

Pattern-Based System
Although the parameter-based method described above should provide for most use cases, the alternative pattern-based system gives some extra flexibility for more complicated scenarios. To utilize the pattern-based system, instead of describing routers as dictionaries of routing parameters, you declare two lists (or tuples) of 2-tuples, routes_in, and routes_out. Each tuple has two elements: the pattern to be replaced and the string that replaces it. For example:-
routes_in = (
('/ninjas', '/coding/help'),
)
routes_out = (
('/coding/help', '/ninjas'),
)