Error Pages

Set up Redirects and error codes

🚧

This feature has been deprecated.

As of March 2023, we've deprecated this functionality. You can still create Custom Pages but you will not be able to set a page in your Guides or API Reference to "API Error".

There are a few types of error pages you can configure:

Error Codes for Your Product

Say your product pops up an error code. You can be extra helpful, and easily link from that error code to a documentation page with tips for resolving that error.

Add an error code link to a doc page by selecting the page in your project dashboard, then selecting API Error in the page type dropdown at the top left.

941

Add API error code to page.

Custom Error Pages

You can create custom error pages to display to your users if they try, for example, to access a broken link. Found under Configuration > Error Pages.

404 Page

We show our generic 404 page by default when a customer tries to access a broken link.

1374

Our generic 404 page.

Use a Custom Page as your 404 message instead for a look that better represents your brand.

1173

Redirects

You can also set up 301 redirects if there is no matching ReadMe page. We'll check it to see if there's a redirect rule for the URL. You can use this to redirect your old non-ReadMe paths to your new site when migrating to ReadMe. Use the format "oldurl -> newurl" (for example, "/documentation/test -> /docs/test"), with one per line. You must redirect from relative paths (i.e., paths that start with a "/" and that come after the main site domain).

Here's some examples:

/docs/top-feature-requests -> /docs/feature-requests
/docs/getting-started -> /docs/get-started
/docs/ios-sdk -> http://github.com/company/ios-sdk

/google -> http://google.com
/old/([a-z]*) -> /new/$1
\w* -> /custom-error-page

📘

Update (June 2020)

When changing the slug of a ReadMe page, there is no need to set up a redirect if this is the only change you intend to make to the page slug. ReadMe takes care of it behind-the-scenes.

This logic applies to the most recent slug change. For example, if you have a page slug set to dog-0 and re-name it to dog-1, ReadMe will take care of the redirect. If, however, you re-name the slug again to dog-2, ReadMe will auto-redirect from dog-1 to dog-2 but you'll have to create a re-direct for the initial dog-0 page, otherwise your users will encounter a 404 if they click that URL.

🚧

Cannot redirect from hash url

It is not possible to redirect from a hash URL like https://readme.readme.io/v2.0/reference#api-specification but it is possible to redirect to a hashed URL

Regular Expressions

You can use regular expressions! It uses JavaScript-style regexes, and must be a full match. To use a captured value on the redirect, use $1 (or 2, 3, etc).

If you your URL includes symbols, remember to escape them using the backslash \.

If you want a catch-all, use \w*.

Troubleshooting

  • Browsers cache these redirects, so changes might not work immediately.
  • Regexes must be a complete match, not a partial match. You can't use ^ or $, because they're appended automatically.
  • Redirects are tested in order they're written, and the first match is used.
  • Redirects are for 404 pages only, if the page exists, it will not redirect.

📘

This feature is only available for the Business and Enterprise plans.