iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
To redirect a WordPress URL, send requests for the old address to the new one with either a server rule, a PHP redirect, or a dashboard plugin. Use a 301 when the move is permanent and a temporary 302 while testing or when the old address will return later. The best method depends on the access you have: WordPress administrators can use the Redirection plugin, developers can use PHP, and server administrators can use Apache or Nginx rules.
What a WordPress redirect does
A redirect is an HTTP response that tells a browser, crawler, or other client to request a different URL. For example, a request for /old-page/ can be sent to /new-page/ without leaving visitors at a broken address.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →The source and destination should be planned precisely. Decide whether the destination uses HTTPS, whether it ends with a trailing slash, and whether it is on the same host. A redirect that points to a slightly different variant can create an unnecessary extra hop or send visitors to the wrong page.
301 versus 302
| Status | Use it when | Typical WordPress example |
|---|---|---|
| 301 Moved Permanently | The old URL has been replaced and should no longer be the canonical address. | A page was renamed, a permalink changed, or content moved permanently. |
| 302 Found | The change is temporary or you are testing the destination before committing to a permanent move. | A short campaign, maintenance destination, or temporary experiment. |
WordPress’s wp_redirect() function defaults to a 302 response, so a permanent move must pass an explicit 301 status. Other 3xx codes may be useful for specialized workflows; the Redirection plugin exposes 301, 302, 303, 304, 307, and 308 choices.
#1 Best Overall
Choose the implementation that matches your access
| Method | Access required | Strengths | Limitations |
|---|---|---|---|
| Redirection plugin | WordPress administrator access | Dashboard rules, 404 logs, regular expressions, permalink migration, and Apache/Nginx exports. | Adds a WordPress-managed layer and is less suitable when you need rules to run before WordPress loads. |
| PHP | Ability to deploy a custom plugin or edit a tightly controlled theme | Precise conditional logic, including decisions based on WordPress page state. | PHP must execute correctly, and execution must be stopped after the redirect. |
Apache .htaccess |
Access to the site’s Apache per-directory configuration | Runs before WordPress and is portable across WordPress code changes. | A syntax or placement error can affect the whole site; the file must be backed up. |
| Nginx | Permission to change the host’s server block and reload configuration | Runs at the web-server layer and avoids loading WordPress for simple redirects. | Exact placement and deployment depend on the hosting environment. |
For a small number of editorial redirects, the plugin is usually the least technical route. Use PHP when the destination depends on WordPress conditions. Use Apache or Nginx when you control the server and want the redirect handled before the application starts.
Prepare the source and destination URLs
- Record the exact old path. Include the path after the domain, and check its capitalization and trailing slash. A rule for
/old-page/is not necessarily the same as one for/old-page. - Choose one final destination. Prefer the canonical HTTPS and slash form that visitors should use, rather than redirecting first to an intermediate variant.
- Choose the status code. Select 301 for a permanent replacement and 302 for a temporary or test destination.
- Check whether the destination is local or external. Local destinations can be validated with
wp_safe_redirect(). A deliberately hard-coded external destination can usewp_redirect(). - Plan a rollback. Save the previous rule, plugin setting, or server configuration so you can remove the redirect if the destination is wrong.
Method 1: Create a redirect with the Redirection plugin
The official WordPress.org Redirection plugin provides a dashboard workflow for people who do not want to edit PHP or server configuration. Its documented features include redirect rules, 404 monitoring, regular-expression matching, permalink migration, and exports for Apache .htaccess and Nginx.
Free tools Windows power users keep installed
One-click scans. No signup required.
Install and open the redirect manager
- In the WordPress dashboard, open Plugins and choose Add New.
- Search for Redirection, verify that you have selected the official plugin listing, and install and activate it.
- Open the plugin’s setup or redirect-management screen. Complete the initial setup if it is shown.
Create the rule
- Enter the old path as the source URL, such as
/old-page/. Use the path expected by the plugin rather than pasting an accidental duplicate domain. - Enter the complete destination path or URL, such as
/new-page/. - Select the HTTP code. Choose 301 for a permanent move or 302 for a temporary change.
- Save the rule, then request the old address in a private browser window or an HTTP client.
Use advanced plugin features when they solve a specific problem
- Regular expressions: Match a family of old URLs when a single literal rule is not enough. Test the expression against representative paths before enabling it.
- Permalink migration: Use the migration workflow when a site’s permalink structure has changed and many old paths must be mapped.
- 404 logs: Review requests that reach a missing page, identify legitimate old URLs, and add targeted rules instead of guessing.
- Server exports: Export Apache or Nginx rules when you later move a redirect from the WordPress layer to the web server.
Keep plugin rules specific. A broad regular expression or catch-all redirect can conceal broken links and send unrelated pages to the same destination.
Method 2: Add a redirect in PHP
PHP is appropriate when the redirect belongs to a custom plugin or a tightly controlled theme condition, such as redirecting one WordPress page based on its page identity.
Rank #2
Use a local destination safely
<?php
if ( is_page( 'old-page' ) ) {
wp_safe_redirect( home_url( '/new-page/' ), 301 );
exit;
}
This example checks for the page identified by old-page, builds a local destination with home_url(), sends a 301 response, and stops execution. Change the status to 302 while the move is temporary or being tested.
Choose between wp_safe_redirect() and wp_redirect()
Use wp_safe_redirect() when the destination should be local or could be influenced by request data. It validates the destination host against allowed hosts and falls back if the URL is unsafe. This protects a redirect that might otherwise be turned into an unintended external destination.
Use wp_redirect() for a deliberately hard-coded external destination when host validation is not required. Pass the status explicitly for a permanent move:
<?php
wp_redirect( 'https://example.com/new-location/', 301 );
exit;
Do not omit the final exit;. The WordPress developer reference states that wp_redirect() does not exit automatically and should almost always be followed by exit;. Without termination, the rest of the request can continue running and produce output or side effects after the redirect has been sent.
Deploy PHP without creating theme maintenance problems
- Prefer a small custom plugin for a site-specific rule so a theme change does not remove it.
- If the rule is placed in a theme, use a theme that you control and keep a copy of the previous file.
- Make the condition narrow enough that it cannot redirect the destination page back to itself.
- Test both the condition that should redirect and a nearby URL that should continue normally.
Method 3: Add a redirect in Apache .htaccess
Apache uses .htaccess as a per-directory configuration file. A rewrite rule can redirect the request before WordPress’s normal routing handles it.
Back up the file and preserve WordPress’s block
Download or copy the existing .htaccess file before editing it. Keep the existing # BEGIN WordPress and # END WordPress block intact. Put custom redirect rules before WordPress’s catch-all rewrite block so the specific rule is evaluated first.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Add a literal path rule
RewriteEngine On
RewriteRule ^old-page/?$ /new-page/ [R=301,L]
In this per-directory pattern, the optional /? allows the source path with or without its final slash. The R=301 flag sends a permanent response, and L stops processing further rewrite rules after a match. Replace both paths with your own values and use R=302 for a temporary redirect.
Check Apache changes safely
- Save the backup and the edited file.
- Request the old URL immediately.
- If the server returns an error or the site stops routing correctly, restore the backup before making further changes.
- After the rule works, test the destination and a URL that should still be handled by WordPress.
Method 4: Add a redirect in Nginx
Nginx rules belong in the server configuration, not in .htaccess. A simple permanent redirect can use:
Rank #4
rewrite ^/old-page/?$ /new-page/ permanent;
The exact file and location depend on the host’s server block and deployment process. Have the person or system that manages the Nginx configuration validate the change and reload the configuration safely. If you prefer to design rules in WordPress first, the Redirection plugin documents an Nginx export that can be adapted to the server’s configuration.
Use the same source-and-destination checks as with Apache: confirm the slash form, avoid pointing a rule at itself, and use a temporary response while testing if the move is not final.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesVerify that the redirect works
Do not treat a page that eventually appears in the browser as proof that the rule is correct. Verify the response, destination, and behavior of the complete redirect path.
Check the HTTP response
Request the old address with a browser’s network tools or an HTTP client. Confirm that the response is the intended 301 or 302 and that its Location value exactly matches the chosen destination.
Best Value
curl -I https://example.com/old-page/
The response should identify the expected 3xx status and a Location header. If the header points to another redirect, follow the chain and correct the intermediate rule where possible.
Check the final page
- Open the destination and confirm it loads successfully.
- Check that the final URL has the intended HTTPS and trailing-slash form.
- Look for a loop in which the source and destination rules send requests back to each other.
- Check for a chain in which the old URL redirects through one or more intermediate URLs before reaching the final page.
- For conditional PHP rules, test both logged-in and logged-out requests and any other condition used by the code.
- After a plugin rule is published, review its 404 logs for missed old URLs or an unexpectedly broad match.
Common failures and how to fix them
| Symptom | Likely cause | Fix |
|---|---|---|
| The browser remains on the old page. | The rule was not saved, does not match the exact source path, or a higher-priority rule handles the request first. | Compare the requested path character for character, confirm the rule is active, and place server rules before WordPress’s catch-all block. |
| A permanent move returns 302. | wp_redirect() was called without a status, or the plugin was left on its temporary default. |
Pass 301 explicitly and verify the response with an HTTP client. |
| PHP sends the redirect but the page still executes. | The code omitted termination after the redirect function. | Add exit; immediately after wp_safe_redirect() or wp_redirect(). |
| Visitors are sent to an unsafe external host. | A destination influenced by input was passed without host validation. | Use wp_safe_redirect() for local or input-influenced destinations and confirm the allowed host. |
| Apache rules have no effect. | The rule is below the WordPress catch-all block, the pattern includes an incorrect leading path, or the file was not loaded. | Back up the file, move the custom rule above the managed block, check the per-directory pattern, and test again. |
| The site returns a server configuration error. | A syntax or placement error was introduced in .htaccess or Nginx configuration. |
Restore the backup, validate the configuration through the host’s deployment process, then reapply one tested rule. |
| The redirect loops. | The destination also matches the source condition, or two rules point to each other. | Request each URL separately, identify the first repeated destination, and narrow or remove the conflicting rule. |
| Some old URLs still produce 404 responses. | A permalink migration or regular-expression pattern did not cover every old path. | Use the plugin’s 404 log to identify real misses and add precise rules or correct the expression. |
Redirects at scale: rules, regular expressions, and migration
One-to-one redirects are easiest to audit. When a permalink structure changes, a regular expression can represent a family of old paths, but it also increases the chance of matching URLs that should not move. Start with a narrow expression, test several valid and invalid examples, and inspect the resulting Location header for each.
For a large migration, maintain a source-to-destination list before publishing rules. Remove duplicate destinations where possible, avoid chains, and keep the old paths available for verification. The Redirection plugin’s permalink-migration tools and 404 logs can help discover and monitor these mappings; Apache and Nginx exports can move the finished rules to the server layer.
Security and maintenance checklist
- Use 301 only after the destination is final; use 302 during a temporary test.
- Use
wp_safe_redirect()for local destinations and any URL that could be affected by request input. - Always terminate PHP execution after a redirect call.
- Back up
.htaccessor server configuration before editing. - Keep custom Apache rules above WordPress’s generated catch-all block.
- Use the host’s approved process for Nginx validation and reloads.
- Check status,
Location, final URL, loops, and chains with an HTTP client. - Review conditional behavior for logged-in and logged-out visitors.
- Use 404 logs after a migration to find legitimate old URLs that still need rules.
- Remove obsolete temporary rules so future editors do not inherit confusing behavior.
Which WordPress redirect method should you use?
Choose the Redirection plugin when you need an editor-friendly dashboard, 404 monitoring, regular expressions, or import/export features and do not control the server. Choose PHP when a redirect must depend on WordPress logic and you can deploy a custom plugin or controlled theme code. Choose Apache or Nginx when you manage the web server and want simple rules to run before WordPress.
Whichever method you select, define the exact source and final destination first, choose 301 or 302 deliberately, and verify the actual HTTP response instead of relying only on what a browser displays.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

