> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Define routes for your multiple apps

> Learn about the many ways you can define routes between your apps.

When you set up a project containing multiple applications,
all of your apps are served by a single [router for the project](https://developer.upsun.com/docs/routes).
Each of your apps must have a `name` that's unique within the project.
To define specific routes for one of your apps, use this `name`.

There are various ways you can define routes for multiple app projects.

In this project, you have a CMS app, two frontend apps (one using Symfony and another using Gatsby),
and a Mercure Rocks server app, defined as follows:


&#x20;   applications:
&#x20;     admin:
&#x20;       source:
&#x20;         root: admin
&#x20;       type: nodejs:\{\{version:nodejs:latest}}
&#x20;     api:
&#x20;       source:
&#x20;         root: api
&#x20;       type: php:\{\{version:php:latest}}
&#x20;     gatsby:
&#x20;       source:
&#x20;         root: gatsby
&#x20;       type: nodejs:\{\{version:nodejs:latest}}
&#x20;     mercure:
&#x20;       source:
&#x20;         root: mercure/.config
&#x20;       type: golang:\{\{version:golang:latest}}

> [!NOTE]
>
> You don't need to define a route for each app in the repository.
> If an app isn't specified, then it isn't accessible to the web.
> One good example of defining an app with no route is when you [use Git submodules](https://developer.upsun.com/docs/configure-apps/multi-app/project-structure.md#split-your-code-source-into-multiple-git-submodule-repositories) and want to [use a source operation to update your submodules](https://developer.upsun.com/docs/development/submodules.md#update-submodules).
>
> You can also achieve the same thing by defining the app as a [`worker`](https://developer.upsun.com/docs/configure-apps/image-properties/workers).

Depending on your needs, you could configure the router container
[using subdomains](#define-routes-using-subdomains) or using [subdirectories](#define-routes-using-subdirectories).

### Define routes using subdomains

You could define routes for your apps as follows:

```yaml .upsun/config.yaml theme={null}
routes:
  "https://mercure.{default}/":
    type: upstream
    upstream: "mercure:http"
  "https://{default}/":
    type: upstream
    upstream: "api:http"
```

So if your default domain is `example.com`, that means:

* `https://mercure.example.com/` is served by your Mercure Rocks app (`mercure`).
* `https://example.com/` is served by your Symfony frontend app (`api`).

> [!NOTE]
>
> Using a subdomain might [double your network traffic](https://www.nickolinger.com/blog/2021-08-04-you-dont-need-that-cors-request/),
> so consider using a path like `https://{default}/api` instead.

### Define routes using subdirectories

Alternatively, you could define your routes as follows:

```yaml .upsun/config.yaml theme={null}
routes:
  "https://{default}/":
    type: upstream
    upstream: "api:http"
  "https://{default}/admin":
    type: upstream
    upstream: "admin:http"
```

Then you would need to configure each app's `web.locations` property to match these paths:


&#x20;   applications:
&#x20;     admin:
&#x20;       source:
&#x20;         root: admin
&#x20;       type: nodejs:\{\{version:nodejs:latest}}
&#x20;       ...
&#x20;       web:
&#x20;         locations:
&#x20;           '/admin':
&#x20;             passthru: '/admin/index.html'
&#x20;             root: 'build'
&#x20;             index:
&#x20;               \- 'index.html'
&#x20;     api:
&#x20;       source:
&#x20;         root: api
&#x20;       type: php:\{\{version:php:latest}}
&#x20;       ...
&#x20;       web:
&#x20;         locations:
&#x20;           "/":
&#x20;             passthru: "/index.php"
&#x20;             root: "public"
&#x20;             index:
&#x20;               \- index.php

&#x20;   routes:
&#x20;     "https\://\{default}/":
&#x20;       type: upstream
&#x20;       upstream: "api:http"
&#x20;     "https\://\{default}/admin":
&#x20;       type: upstream
&#x20;       upstream: "admin:http"

So if your default domain is `example.com`, that means:

* `https://example.com/` is served by your Symfony frontend app (`api`).
* `https://example.com/admin` is served by your Admin app (`admin`).

Note that in this example, for the configuration of your `admin` app,
you need to add the URL suffix `/admin` as both an index in the `web.locations` and a value for the `passhtru` setting.

For a complete example, [go to this project on GitHub](https://github.com/platformsh-templates/bigfoot-multiapp/tree/submodules-root-subfolders-applications).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.