You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cloud/project/routes.md
+56-31Lines changed: 56 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ redirect_from:
8
8
- /cloud/project/project-conf-files_routes.html
9
9
---
10
10
11
-
The `routes.yaml` file in the `.magento/routes.yaml` directory defines routes for your {{ site.data.var.ece }} Integration, Staging, and Production environments. Routes determine how Magento processes incoming HTTP requests.
11
+
The `routes.yaml` file in the `.magento/routes.yaml` directory defines routes for your {{ site.data.var.ece }} Integration, Staging, and Production environments. Routes determine how Magento processes incoming HTTP and HTTPS requests.
12
12
13
13
{% include cloud/note-pro-missing-self-service-options.md %}
14
14
15
-
The default `routes.yaml` file specifies the route templates for processing HTTP requests on projects that have a single default domain and on projects configured for multiple domains:
15
+
The default `routes.yaml` file specifies the route templates for processing HTTP requests as HTTPS on projects that have a single default domain and on projects configured for multiple domains:
16
16
17
17
```yaml
18
18
"http://{default}/":
@@ -23,8 +23,6 @@ The default `routes.yaml` file specifies the route templates for processing HTTP
23
23
upstream: "mymagento:http"
24
24
```
25
25
26
-
If you do not create a custom `routes.yaml` file, the automated deployment uses the default file.
27
-
28
26
Use the `magento-cloud` CLI to view a list of the configured routes:
The `routes.yaml` file is a list of templated routes and their configurations. You can use the following placeholders in route templates:
44
42
45
-
- `{default}` represents the qualified domain name configured as the default for the project. For example, if you have a project with the default domain `example.com`, the route templates `http://www.{default}/` and `https://{default}/blog` resolve to the following URLs in a production environment:
43
+
- `{default}` represents the qualified domain name configured as the default for the project. For example, if you have a project with the default domain `example.com`, the route templates `https://www.{default}/` and `https://{default}/blog` resolve to the following URLs in a production environment:
46
44
47
45
```text
48
-
http://www.example.com/
46
+
https://www.example.com/
49
47
50
-
https://www.example.com/blog
48
+
https://example.com/blog
51
49
```
52
50
{:.no-copy}
53
51
54
-
In a non-production branch, the project ID and environment ID replace the `{default}` placeholder when the project is deployed.
55
-
56
-
- `{all}` represents all the domain names configured for the project. For example, if you have a project with `example.com` and `example1.com` domains, the route templates `http://www.{all}/` and `https://{all}/blog` resolve to routes for all domains in the project:
52
+
- `{all}` represents all the domain names configured for the project. For example, if you have a project with `example.com` and `example1.com` domains, the route templates `https://www.{all}/` and `https://{all}/blog` resolve to routes for all domains in the project:
57
53
58
54
```text
59
-
http://www.example.com/
60
-
61
-
http://www.example.com/blog
55
+
https://www.example.com/
62
56
63
57
https://www.example1.com/
64
58
65
-
https://www.example1.com/blog
59
+
https://example.com/blog
60
+
61
+
https://example1.com/blog
66
62
```
67
63
{:.no-copy}
68
64
@@ -73,21 +69,49 @@ The `routes.yaml` file is a list of templated routes and their configurations. Y
73
69
{{site.data.var.ee}} also generates routes for every active Integration environment. For Integration environments, `{default}` is replaced with the following domain name:
{{site.data.var.ece}} also supports [multiple applications]({{ site.baseurl }}/cloud/project/project-multi-sites.html) per project. Each project has a single `routes.yaml` file that defines which request is routed to which application.
84
+
If your Cloud project supports multiple stores, follow the route configuration instructions for [multiple websites or stores]({{ site.baseurl }}/cloud/project/project-multi-sites.html).
85
+
86
+
## Route protocols
87
+
88
+
All environments support both HTTP and HTTPS automatically.
89
+
90
+
- If the configuration specifies only the HTTP route, HTTPS routes are created automatically, allowing the site to be served from both HTTP and HTTPS without requiring redirects. For example, if you have project with the default domain `example.com`, the record `http://{default}/` resolves to the following URLs:
91
+
92
+
```text
93
+
http://example.com/
94
+
95
+
https://example.com/
96
+
```
97
+
{:.no-copy}
98
+
99
+
- If the configuration specifies only the HTTPS route, then all HTTP requests redirect to HTTPS. For example, for the default domain `example.com`, the route `https://{default}/` resolves to URL `https://example.com/` and redirects `http://example.com/` to `https://example.com/`.
100
+
101
+
We recommend serving all pages over TLS. For this configuration, you must configure redirects for all unencrypted request to the TLS equivalent using one of the following methods:
102
+
103
+
- Change protocol to HTTPS in `routes.yaml`.
104
+
105
+
```yaml
106
+
"https://{default}/":
107
+
type: upstream
108
+
upstream: "mymagento:http"
109
+
"https://{all}/":
110
+
type: upstream
111
+
upstream: "mymagento:http"
112
+
```
113
+
114
+
- For Staging and Production environments, we recommend enabling the [Force TLS on Fastly](https://support.magento.com/hc/en-us/articles/360006296953-Redirect-HTTP-to-HTTPS-for-all-pages-on-Cloud-Force-TLS-) option from the Magento Admin UI. When you use this option, Fastly handles the redirection to HTTPS, so you do not have to update the `routes.yaml` configuration.
91
115
92
116
## Route options
93
117
@@ -103,31 +127,35 @@ Property | Description
103
127
104
128
## Simple routes
105
129
106
-
The following sample routes the apex domain and the `www` subdomain to the `frontend` application. This route does not redirect HTTPS requests:
130
+
In the following examples, the route configuration routes the apex domain and the `www` subdomain to the `mymagento` application. This route does not redirect HTTPS requests.
131
+
132
+
**Example 1:**
107
133
108
134
```yaml
109
135
"http://{default}/":
110
136
type: upstream
111
-
upstream: "frontend:http"
137
+
upstream: "mymagento:http"
112
138
113
139
"http://www.{default}/":
114
140
type: redirect
115
141
to: "http://{default}/"
116
142
```
117
143
118
-
The following sample route does not redirect from the `www` to the apex domain; instead, it serves from both:
144
+
In the following example, the route configuration does not redirect URLs from the www domain to the apex domain. Instead, requests are served from both the www and apex domain.
145
+
146
+
**Example 2:**
119
147
120
148
```yaml
121
149
"http://{default}/":
122
150
type: upstream
123
-
upstream: "frontend:http"
151
+
upstream: "mymagento:http"
124
152
125
153
"http://www.{default}/":
126
154
type: upstream
127
-
upstream: "frontend:http"
155
+
upstream: "mymagento:http"
128
156
```
129
157
130
-
In the first sample, the server responds directly to a request of the form `http://example.com/hello`, but it issues a _301 redirect_ for `http://www.example.com/mypath` (to `http://example.com/mypath`).
158
+
In this example, the server responds directly to a request of the form `http://example.com/hello`, issuing a _301 redirect_ for requests with the URL pattern `http://www.example.com/mypath`. These requests redirect to the apex domain, for example `http://example.com/mypath`.
131
159
132
160
## Wildcard routes
133
161
@@ -170,10 +198,7 @@ See more information about [caching]({{ site.baseurl }}/cloud/project/project-ro
170
198
As discussed in more detail in [Redirects]({{ site.baseurl }}/cloud/project/project-routes-more-redir.html), you can manage complex redirection rules, such as *partial redirects*, and specify rules for route-based [caching]({{ site.baseurl }}/cloud/project/project-routes-more-cache.html):
0 commit comments