Import your own code

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.

Each language and framework may have additional attributes that you will need to include in .platform/routes.yaml depending on the needs of your application. To find out what else you may need to include to configure your routes, consult

  • The Routes documentation for Platform.sh The documentation goes into far more extensive detail of which attributes can also be included for route configuration, and should be used as your primary reference.
  • Language-specific templates for Platform.sh Projects Compare the .platform/routes.yaml file from the simple template above to other templates when writing your own.

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.