301 and 302 Redirect Rules
Redirects, or rewrites, are rules you can create to have certain URLs automatically go to a new location anywhere on the internet. If you have adjusted the URL structure on your website, and need former links to redirect to the new ones, you will need to configure redirect rules to ensure your pages can be found and maintain any SEO ranking.
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
There are several ways to configured redirect rules, with the most effective ways being determined by the number of redirects.
It is always recommended to consolidate as many rules as possible using RegEx, regardless of the number of redirects needed.
Fewer Than 1000 Redirects
- Redirects can be added to WP Engine’s Nginx configuration
- Add redirects rules to the Redirection plugin
- Manage redirects in Yoast SEO Premium‘s redirect manager
More Than 1000 Redirects
- Importing redirects into the WP Engine Nginx configuration will not be efficient at this quantity, due to bloating and overhead.
- We suggest loading redirects into the Redirection plugin or, if you’re using Yoast SEO, manage redirects in Yoast Premium
Bulk Migrate Redirects from the .htaccess
Starting with PHP 7.4, redirects placed in the .htaccess file will not function. All of the recommended redirect alternatives below offer bulk importing of Apache (.htaccess-formatted) redirects. This means importing existing redirects from the .htaccess can be done quickly and easily, and does not require redirects be moved one at a time. Learn more about .htaccess deprecation here.
- Bulk import redirects to the WP Engine Nginx configuration
- Bulk import redirects to Redirection plugin
- Bulk import redirects to Yoast Premium redirect manager
Access 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 a Redirect Rule
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 Rule 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 tell the rule to only redirect requests to
ilovepuppies.comand not redirect traffic coming into the same path through the domains
- For example, say this environment has the following domains:
- For multisite networks with Domain Wildcarding enabled, you will also see an option called Use Domain Wildcards (Advanced). This option will use both the mapped domain and any wildcard 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 variable referrer.
- Required field
- The URL path the redirect will result in
- Does not support RegEx
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
NOTE: Break type redirects have additional requirements for the Domain field. See the Break section below for more information.
If I have the following domains on this environment:
The above rule would create all of 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 – A “break” redirects the user to a different page on the same domain, without updating the address bar or sending a response code (301 or 302) is not returned. A break is also called also called an internal redirect, this can be used to “mask” a redirect. For example:
- Domain: Select your domain
- Cannot be “All domains”
- Domain must match the Destination field
- Domain must match the Source field
- Do not use HTTP or HTTPS
- This will load the content from
/backend_page?id=123while keeping the URL in the address bar as
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.