Redirects are rules to have pages redirect automatically to a new location. These are great tools to use if you adjusted the pages names on your site and need former links to redirect to the new ones.
NOTE: If you are in the process of migrating your account and you are not using redirects, you can move on to the next section of the migration process.
Redirects on WP Engine
At WP Engine we use a server setup that utilizes the Nginx over Apache. All requests hit Nginx first, which means redirects are served more quickly when placed there. Apache is slower and is also subject to caching, which can cause redirects to not work as intended.
You’ll want to setup all of your 301 and 302 redirects in your User Portal (which serves from Nginx) instead of other ways such as using the
.htaccess file or using plugins (which serves from Apache).
Access the Redirect Rules
- Login to the User Portal
- Select the environment name you want to configure a redirect for
- NOTE: Redirects for a specific domain will only work if the domain is also mapped to the same environment
- Select Redirect Rules
Add Redirect Paths
The most common redirect is to simply have one page redirect to another. To set this up, click the New Redirect Rule button.
- Click New Redirect Rule
- You will be presented with a window like the following
- Configure your redirect and click Save or Add another
Redirect Rules Configuration Fields
It’s important to note that redirect rules will be read from top to bottom. If a rule is not specific
- A simple title to describe what the redirect is for
- The name does not impact the redirect itself
- Can be left blank, if a name is not given, a number will be applied
- Use the dropdown to select the domain(s) this redirect will work for.
- Select All Domains to allow the redirect to work for any domain mapped to this environment.
- Select a specific domain mapped to your account to only apply the redirect to that domain, and no other domains.
- For example, say this environment has the following domains:
ilovepuppies.comfrom the dropdown would make the rule only redirect requests to
ilovepuppies.comand would not redirect traffic coming into the same path through
- For example, say this environment has the following domains:
- If you do not see a domain listed that you’d like to set a unique redirect for, make sure the domain is mapped and remove any redirects to other domains.
Reading the URL that you want to map from the left to the Right, the “Source” part will be whatever follows the domain. When looking at
http://domain.com/testing/123, the “Source Input” would be:
- Required field
- The original URL path that when requested will be redirected
- Supports RegEx (A great tool to use to test your RegEx is RegEx Pal)
- Do not enter the domain here
- Start with the symbol
^to say “begin here”, this is required for the source field unless you include the domain
- End with the symbols
/?$to say “end here”
- You cannot match a Query String, or Argument in the Source Input. You will need to look in the Advanced Settings in order to do this (details below).
NOTE: If you capture something in the Source Input by placing parentheses around it, then you can call it later in the “Destination” using the
$1 variables referrer.
- Required field
- The exact URL path the redirect will result in
- Does not support RegEx
- Include the full domain and protocol (http/https), as you’d see it in the browser
- This can be any domain. The domain in this field does not need to be a domain added to your environment or even a domain that you own.
NOTE: Variables set in the Source field can be called in the Destination field. With a Source Input of
^/testing/(123) and a Destination of http://domain.com/$1, then the Ending URL will be
If I have the following domains on this environment:
The above rule would create the following redirects:
Clicking on Advanced Settings will reveal two items:
An arg is another name for a URL query. You can spot them by a question mark in the URL. The “arg” is everything after the
? symbol. For example, in the URL
domain.com/testing?input=thisthe arg would be
If do not you wish to have the arg carried over and appended to the destination, you must also add a
? to the end of your Destination source field.
If you do wish to have the arg appended to the destination, no question mark is necessary in the Destination source field.
EX: If the Source is
domain.com/testing?input=this and the Destination is
https://wpengine.com/testingthis/, this will redirect the URL to
This can be changed based on your preference of response codes.
301 Permanent – Default setting. Tells search engines to remove the old URL from the search index and update it with the new one.
302 Temporary – Tells search engines not to update their index. The purpose is to maintain SEO rank on the original Source URL. EX: Redirecting your home page to a “coming-soon” page.
Break – Still redirects but does not return a response code, also called an internal redirect. This will allow you to have the content of one page load, while the URL remains the same in the browser’s address bar. Both the source and destination must have the same domain. This can be used to “mask” a redirect.
Submitting Redirects in Bulk
If you’d like to import redirects in bulk this is entirely possible. You will need to reach out to WP Engine Support with a formatted file ready to import.
Each rule must be on its own line to import properly and formatted similarly to the examples below.
Our User Portal supports up to about 1000 redirects to be imported. After about 1000 redirect rules, we’ve seen performance issues, so we strongly recommend keeping this list under that amount.
Before continuing, we recommend taking the following steps:
- Perform an audit of the redirect rules. See if any are no longer needed, or if any of them follow the same pattern and can be grouped into “rewrites”, where requests matching a specific pattern are redirected based on that pattern.
- Ensure the rules are in a text document (something easy to open and copy/paste from), and formatted like .htaccess redirect rules.*
If these rules are already in your site’s .htaccess file from a previous host, feel free to copy the rules and paste them into a .txt file for our Support team to import for you.
Bulk import formatting examples
Redirect “domain.com/path/match/” to “domain.com/something/”
Alternative format: Redirect “domain.com/path/match/” to “domain.com/something/”
Redirect 301 ^/path/match/?$ http://domain.com/something/
If there are multiple domains on an environment and you wish to redirect a single domain to a specific location
Redirect “domain.com/path/more/anything” to “domain.com/anything”
RewriteRule ^/path/more/(.*) http://domain.com/$1 [R=301,L]
Redirect a domain with an argument (?example-arg=123) on the end: “domain.com/path/match/?example-arg=123” to “domain.com/something/”
Redirect 301 ^/path/match/?example-arg=123 http://domain.com/something/
We use what is called Regular Expressions (also known as Regex) in the Source section of our redirects. Regular Expressions are very useful because they allow you to specifically create more advanced search strings which can be very beneficial for configuring advanced redirects. If you would like to learn more about how they work, please see our Common Regex Used For Redirect Rules article.
When Organizing Redirect Rules, keep in mind that the Rules will be applied from the top to the bottom. For example, if you have a specific rule like
^/testing/123/abc/?$ with the Destination
/123/abc/; and then another more Generic, “Catch All” rule of
^/testing/.* with the destination of
https://wpengine.com/, then you should have the second rule at the bottom of the redirect list, and the first rule at the top.
This will ensure that the two redirects won’t conflict with each other. If you put the second rule at the top, then it will “catch-all” before the more specific rule has a chance to take effect.