|
2 | 2 |
|
3 | 3 | #### 3.1 Determine how to configure Cloud |
4 | 4 |
|
| 5 | +###### How to configure different redirects in this file, which types of redirects should not be configured here |
| 6 | +A route describes how an incoming HTTP request is going to be processed by Magento Cloud. |
| 7 | +Route configuration (from platform.sh) |
| 8 | + |
| 9 | + |
| 10 | +File `.magento/routes.yaml` - defines routes for the Integration environments. |
| 11 | +```yaml |
| 12 | +"http://{default}/": |
| 13 | + type: upstream |
| 14 | + upstream: "mymagento:php" |
| 15 | + |
| 16 | +# whole-route redirects |
| 17 | +"http://www.{default}/": |
| 18 | + type: redirect |
| 19 | + to: http://{default}/ |
| 20 | + |
| 21 | +# partial redirects |
| 22 | +http://test.{default}/: |
| 23 | + type: upstream |
| 24 | + redirects: |
| 25 | + expires: 1d |
| 26 | + paths: |
| 27 | + "/from": { "to": "/destination", code: 308, expires: 2w} |
| 28 | + "/regexp/(.*)/matching": { "to": "http://example.com/$1", regexp: true } |
| 29 | +``` |
| 30 | +
|
| 31 | +Each rule under `paths` is defined by: |
| 32 | + _key_ - expression to match against the request path; |
| 33 | + _value_ - object describing both the destination to redirect with detail on how to handle the redirection; |
| 34 | + |
| 35 | +Value object is defined with the following keys: |
| 36 | +- to: (required) partial ("/destination" or "//destination") or full URL ("http://example.com/"). |
| 37 | +- regexp: (default: false) specifies whether the path key should be interpreted as a PCRE regular expression |
| 38 | + Special arguments in the `to` statement (only if regexp: true) |
| 39 | + - `$is_args`: `?` or empty string |
| 40 | + - `$args`: full query string if any |
| 41 | + - `$arg_foo`: value of the query parameter `foo` |
| 42 | + - `$uri`: full URI of the request |
| 43 | +- prefix: (default: true, not supported if regexp is true) specifies whether we should redirect both the path and all its children or just the path itself |
| 44 | + Example: |
| 45 | + if true: /from redirects to /to and /from/another/path will redirect to /to/another/path |
| 46 | + if false: /from triggers a redirect, but /from/another/path does not. |
| 47 | +- append_suffix: (default: true, not supported if regexp is true or if prefix is false) determines if the suffix is carried over with the redirect |
| 48 | + Example: |
| 49 | + if true: /from redirects to /to/path/suffix in case /from/path/suffix |
| 50 | + if false: /from redirects to /to in case /from/path/suffix |
| 51 | +- code: status codes are 301, 302 (default), 307, and 308 |
| 52 | +- expires: examples of valid values include 3600s, 1d, 2w, 3m |
| 53 | + |
| 54 | +List the configured routes: `magento-cloud environment:routes` |
| 55 | + |
| 56 | +Which types of redirects should not be configured here: |
| 57 | +- Application-driven redirects |
| 58 | +- Fastly |
| 59 | +- Long list of storefront domains (not sure) |
| 60 | +- As a general rule we recommend keeping the defined routes under 100 |
| 61 | +- Let's Encrypt also limits an environment to 100 configured domains |
| 62 | +- Linux kernel limit on environment variables is 32 pages (each page is 4k on x86, so maximum environment variable length of 128KB). So it's a limits for `routes.yaml` |
| 63 | + |
| 64 | +###### How to add these configurations to Staging or Production environments. Magento On-Premises installation migration |
| 65 | + |
| 66 | +###### How to migrate an existing Magento installation into Magento Cloud: Code base, database, media migration |
| 67 | + |
5 | 68 | #### 3.2 Determine how to configure a planned service |
6 | 69 |
|
7 | 70 | #### 3.3 Demonstrate ability to add to your environment |
| 71 | + |
| 72 | +Documentation: |
| 73 | +- [Configure Routes / platform.sh](https://docs.platform.sh/configuration/routes.html) |
| 74 | +- [Configure routes](https://devdocs.magento.com/guides/v2.3/cloud/project/project-conf-files_routes.html) |
| 75 | +- [Redirects / platform.sh](https://docs.platform.sh/configuration/routes/redirects.html) |
| 76 | +- [Redirects](https://devdocs.magento.com/guides/v2.3/cloud/project/project-routes-more-redir.html) |
0 commit comments