Static Site Redirects and Rewrites
You can add redirect and rewrite rules to static sites in the Render Dashboard:
These two rules are used by this very documentation site!
When the path of an incoming request matches a rule’s Source, Render automatically redirects or rewrites the request to the corresponding Destination. For details, see Rule matching and ordering.
Which action to use?
Set each rule’s Action to Redirect or Rewrite according to your needs:
Action | Description |
---|---|
Redirect |
Instructs the browser (or any other client) to switch URLs to the rule’s destination via a Create a redirect rule if you’re moving an existing resource from one path to another (for example, if you move your site’s documentation content from |
Rewrite |
Does not redirect the browser. Instead, your site serves the content from the rule’s destination at the original path. The browser can’t detect that content was served from a different path or URL. Create a rewrite rule if:
|
Rule matching and ordering
Render does not apply redirect or rewrite rules to a path if a resource exists at that path. Instead, Render simply serves the resource at that path. This protects against overwriting valid paths with a rule, especially when using wildcards.
Here’s what the full path-matching process looks like:
If this process results in a redirect to another site path, the process repeats with the new path.
Rule syntax
- Source must be a path (not a full URL). This is matched against the path of the incoming request.
- Destination can be either a path or a full, publicly accessible URL.
Basic examples
Source | Destination |
---|---|
/home | / |
/blog/index.html | /blog |
/web-host | https://render.com |
Wildcards
Use a wildcard (*
) to match arbitrary strings in a path.
- In Source,
*
matches any string that appears starting at that position in the path.- Specify
/*
to match all paths.
- Specify
- In Destination,
*
applies the entire string captured by the wildcard in Source.
Source | Destination | Example Effect |
---|---|---|
/* | /blog/* | /path1/path2 → /blog/path1/path2 |
/* | /index.html | All requests → /index.html |
Placeholders
Use placeholders to include specific path components from Source in Destination:
Source | Destination | Example Effect |
---|---|---|
/blog/posts/:postid | /blog/:postid | /blog/posts/my-post → /blog/my-post |
/updates/:month/:year | /changelog/:year/:month | /updates/03/2024 → /changelog/2024/03 |