Redirects and Rewrites
Since static sites don’t have a server-side component that can redirect or rewrite HTTP requests, Render lets you define redirect and rewrite rules for your static sites in the dashboard.
A Redirect rule instructs the client (usually a browser) to switch URLs and navigate to the destination of the rule. Redirect rules are typically used for old paths that you’d like to redirect to new ones.
In contrast, a Rewrite rule does not change the original URL; it simply serves the content of the rule destination at the original path. The browser can not tell that the content was served from a different path, making it possible to display content from any path on your site on any other path. Rewrite rules are also needed for client-side routing, so frameworks like react-router and Vue Router can handle all requests at
Redirect and rewrite rules are only matched if no existing content is found at a path. This ensures existing content isn’t accidentally overwritten by a rule, and allows wildcard rules to exist without overwriting valid paths.
Once Render determines there is no content on a path, it starts matching your rules in order starting from the top. The first matching rule is applied to the request.
The source must be a relative path. It will be matched with the relative path of the request URL.
The destination can be a relative path or an absolute URL for redirect rules. It must be a relative path for rewrite rules.
You can use wildcards to match arbitrary request paths.
* for wildcard matching in the source path.
* in the destination to represent everything captured by the wildcard in the source path.
|All requests → |
You can use placeholders to use specific parts of the URL in your destination paths.