Static Site Redirects and Rewrites

You can add redirect and rewrite rules to static sites in the Render Dashboard:

Setting redirect and rewrite rules 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:

ActionDescription

Redirect

Instructs the browser (or any other client) to switch URLs to the rule’s destination via a 301 Moved Permanently response code.

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 /documentation to /docs).

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:

  • You want to serve the same content from multiple paths.
  • Your static site uses a framework with client-side routing (such as react-router or Vue Router), and you’ll handle all requests from a single path like /index.html.

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:

Yes
No
Yes
No
Incoming request
to path /abc
Does a resource exist
at /abc?
Serve that
resource
Does /abc match any
redirect or rewrite rule?
Apply the first
matching rule
(starting from the
top of the list)
Return
404 Not Found

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

SourceDestination
/home/
/blog/index.html/blog
/web-hosthttps://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.
  • In Destination, * applies the entire string captured by the wildcard in Source.
SourceDestinationExample Effect
/*/blog/*/path1/path2/blog/path1/path2
/*/index.htmlAll requests → /index.html

Placeholders

Use placeholders to include specific path components from Source in Destination:

SourceDestinationExample 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