Configure routes


The final configuration file you will need to modify in your repository is the .platform/routes.yaml file, which describes how an incoming HTTP request is going to be processed by Platform.sh.

.
├── .platform
│   ├── routes.yaml
│   └── services.yaml
├── .platform.app.yaml
└── < application code >

A minimal configuration .platform/routes.yaml for all languages will look very similar:

# The routes of the project.
#
# Each route describes how an incoming URL is going
# to be processed by Platform.sh.

"https://{default}/":
    type: upstream
    upstream: "app:http"

"https://www.{default}/":
    type: redirect
    to: "https://{default}/"

Configuring the routes can be done using either an absolute URL or a URL template as shown in the examples above that have the form http://www.{default}, where {default} will be substituted by either your configured domain or those automatically generated by Platform.sh.

If you set up a domain of example.com, the route configuration http://www.{default} will be resolved to http://www.example.com/. Your production (master) environment’s routes will be configured according to these rules, but so will each development environment that you activate.

Each route can then be configured with the following properties:

  • type:
    • upstream: serves the application. Takes the form upstream: <application name>:http, using the application name set in your .platform.app.yaml.
    • redirect: configures redirects from http://{default} to your application.
  • cache: controls caching behavior of the route.
  • redirects: controls redirect rules associated with the route.

In the next step, you will be able to see how Platform.sh leverages environment variables to make connecting your application to its services simple.