Redirects allow you to forward visitors from one URL to another.
We support a few different types of redirect:
- WWW to non-WWW (and vice-versa)
- Redirects between alias domains
- Redirects between URLs- these are called Rewrite Rules
We also support regular expressions (Regex) which enable you to do complex redirects.
Redirects can be accessed from the site settings page. To access this, click the menu in the right hand side of a site card and then “Settings”.
Quick Redirects
Quick redirects enable you to implement common redirect types, including:
- Redirecting between www and non-www domains (e.g. from
www.mydomain.com to mydomain.com) and vice versa.
- Redirecting between Aliases (for example, redirecting an alias domain to the main domain).
You can find Quick Redirects under Settings —> Redirects.
Rewrite rules
Rewrite rules allow you to redirect between URLs, or implement more advanced redirect logic.
They work by specifying source and destination URLs in the dashboard. These URLs are relative to the main domain, so /home is equal to https://yourdomain.com/home.
Below we explain how to add a rewrite rule, as well as some of the common types you may encounter.
To create a new rewrite rule, click ‘Create Redirect’:
Enter your Source and Destination as follows:
- Source: The URL you wish to redirect from. This should be specified as a regular expression, starting with
^ and ending in $.
- Destination: This should be the URL you wish to redirect to. Regular expressions are also supported here. You can also specify a full URL (with
https:// at the start) if you wish to redirect to a different site.
- Type: Choose from 301 (permenant) or 302 (temporary) depending on your needs.
Edit or Delete rewrite rule
You can modify or remove a rewrite rule from the redirects page. Changes are applied immediately.
Browser caching can interfere with redirectsBrowsers often cache permanent redirects (301) aggressively. If you are making changes or deleting a redirect and it does not appear to be taking effect, try clearing your browser cache.
Rolling back
We keep a backup copy of your redirect configuration for each site which allows you to roll back. To do this, click the “Restore Previous Version” button. This reverts all of your redirects (including Quick redirects) to the last saved state.
Viewing config
For advanced users you can use the “View Config” button to view the nginx configuration that your redirects are converted to.
Bulk import redirects
You can bulk-import redirects from a CSV file into a Cito site. To do this, click “Import CSV” in the Rewrites section.
The CSV must have the following columns:
- Source path,
- Destination path
- Redirect type (this is optional and defaults to 301).
Note that full URLs in the source column will have their domain stripped. All redirects use exact path matching ($ anchor).
When uploading redirects in bulk, source paths with a query string (e.g. example.com/path.php?query=string) are not supported and will be automatically removed.
About regular expressions
A regular expression (regex) is a sequence of characters that define a search pattern. Regular expressions allow you to create flexible redirects but can be confusing to get to grips with.
Below we’ve provided some common regex syntax examples and some guidance on using them. Note that the order in which you add a redirect is the order in which they are executed.
Here’s some common regex syntax:
| Syntax | Description |
|---|
^ | Denotes the beginning of the line |
$ | Denotes the end of the line |
? | Match the previous 0 or 1 times |
. | Match any single character |
* | Match the previous 0 or more times |
.* | Match any character 0 or more times (wildcard) |
(.*) | Capturing group - contains a wildcard match for any string in the given location |
Examples
Simple page redirect
Redirect https://yourdomain.com/old-url to https://yourdomain.com/new-url:
- Source:
^/old-url$
- Destination:
/new-url
Redirect non-www to www (preserving path)
Redirect https://yourdomain.com/anyurl to https://www.yourdomain.com/anyurl
- Source:
/(.*)$
- Destination:
https://www.domain.com/$1
Redirect all URLs to a new domain (preserving path)
Redirect any URL on your website to it’s equivalent on www.newdomain.com:
- Source:
^(.*)$
- Destination:
https://www.newdomain.com/$1
Wildcard redirect (match multiple URLs)
Redirect https://yourdomain.com/blog/anything to https://yourdomain.com/newblog/anything, preserving the path:
- Source:
^/blog/(.*)$
- Destination:
/newblog/$1
Troubleshooting
ERR_TOO_MANY_REDIRECTS
This is called an infinite redirect loop, and it usually indicates a problem with the rules you’ve created.
You should review each redirect to ensure they do not interact in a way that might cause a loop.
Common causes include:
- When the target URL is included in both the Source and Destination.
- Not using the
$ symbol at the end of the Source field.