Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

The simplest reliable choice depends on who will maintain the redirect. Use the Redirection plugin for an editable list of rules and 404 monitoring, PHP for request-aware logic, or an Apache .htaccess rule for static redirects that should run before WordPress. For a genuinely permanent move, send an explicit 301; use a 302 only while the move is temporary or being tested.

Choose the right redirect method

Method Best for Runs at Maintenance and visibility
Redirection plugin Editors, many rules, changed post URLs and 404 follow-up WordPress Point-and-click management, rule history and 404 reports
PHP Conditional redirects based on the request or application state WordPress Requires developer access and careful testing
.htaccess Static path rules on an Apache server Web server, before WordPress Fast, but editing errors can affect the whole site

301 versus 302: which status should you send?

A 301 tells browsers, crawlers and intermediaries that the old URL has moved permanently. Use it when replacing a slug, consolidating content or retiring an old page in favor of a lasting destination.

A 302 indicates a temporary move. WordPress’s wp_redirect() and wp_safe_redirect() functions default to 302, so specify 301 explicitly for a permanent redirect. The Redirection plugin also exposes other 3xx responses, including 303, 304, 307 and 308; select one only when its HTTP semantics fit your request and deployment design.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redirect a URL with the Redirection plugin

This is usually the clearest option for a non-developer or a site with a growing redirect inventory. The official Redirection plugin listing says it can create redirects automatically when a post URL changes, lets administrators add rules without hand-editing .htaccess, and records 404 errors.

  1. In the WordPress dashboard, open Plugins → Add New.
  2. Search for Redirection, install the official plugin, and activate it.
  3. Open Tools → Redirection and complete its initial setup if prompted.
  4. Create a redirect with the old path as the source and the new URL or path as the target.
  5. Choose 301 for a permanent move, or 302 for a temporary one, then save the rule.
  6. Visit the old URL in a fresh browser request and confirm that it reaches the intended destination.

Before using any plugin in production, check its current WordPress compatibility and release status. Those details change over time. Review the 404 view regularly, but remove duplicate or obsolete rules so a request does not pass through several redirects.

Redirect conditionally in PHP

PHP is useful when the destination depends on the request, a logged-in state or another application condition. Run the logic before output, commonly from a suitable hook such as template_redirect. Keep the match narrow and make sure the destination cannot satisfy the same condition, or you can create a loop.

Hard-coded external destination

For a destination you deliberately hard-code, WordPress documents this pattern:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wp_redirect( 'https://example.com/new-page/', 301 );
exit;

wp_redirect() sends the headers but does not stop PHP execution. Always call exit; immediately afterward; otherwise later code may render output or change the response.

Local or potentially untrusted destination

Use the safe variant when the target is local or could be influenced by request data:

wp_safe_redirect( home_url( '/new-page/' ), 301 );
exit;

wp_safe_redirect() performs a local redirect using wp_redirect(), validates the destination host against allowed hosts, and uses a fallback when the host is not allowed. Do not pass an arbitrary user-supplied URL to wp_redirect().

Example with a conditional match

add_action( 'template_redirect', function () {
    if ( is_page( 'old-page' ) ) {
        wp_safe_redirect( home_url( '/new-page/' ), 301 );
        exit;
    }
} );

Adapt the condition to your site and test both the source and destination. A theme or custom plugin is generally a safer home for this logic than editing WordPress core files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add a redirect in Apache .htaccess

.htaccess is Apache’s distributed, per-directory configuration file. WordPress commonly uses the document-root file for pretty-permalink rewrite rules. This method is appropriate only when Apache serves the site and you can edit the correct file.

For a permanent path redirect, add a rule such as:

Redirect 301 /old-page/ https://example.com/new-page/
  1. Make a backup of the existing document-root .htaccess.
  2. Place the custom rule in the correct directory and preserve the existing WordPress rewrite block.
  3. Save the file, then request the old URL and inspect the response.

A malformed file can break routing. This syntax is not portable to Nginx, which uses different server configuration. If you do not control the server configuration, use a plugin or ask the host or administrator to add the rule.

Verify that the redirect works

Check more than the final page. The old address should return the intended 3xx status and a Location header pointing to the correct destination.

  • Test a fresh private-window request so an old browser cache is less likely to mislead you.
  • Check both trailing-slash forms, and test HTTP versus HTTPS or alternate host names when those variants exist.
  • Confirm that the destination does not redirect back to the source or through an unnecessary chain.
  • Use a command-line header request when available: curl -I https://example.com/old-page/. Look for the status and Location values.
  • If the result appears cached, retry from another browser or network; a browser, proxy or CDN may have stored the response.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

Redirect loop

The source pattern may also match the destination, or the rule may conflict with a trailing-slash, scheme or host variant. Narrow the source condition and test the exact final URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wrong status code

If a permanent move is returning 302, specify 301 in the plugin, PHP call or server rule. Remember that WordPress redirect functions default to 302.

Query strings behave unexpectedly

Preserve parameters only when they remain meaningful at the new destination. Otherwise remove or normalize them deliberately in the rule rather than passing tracking or obsolete parameters forever.

Redirect works but visitors still see the old page

Clear or bypass browser, proxy and CDN caches, then check the returned headers from a fresh request. Also update internal links so visitors do not take an avoidable redirect hop.

Unsafe external redirect

Never trust a destination assembled directly from user input. Use a known local path with wp_safe_redirect(), or validate an external host against an explicit allowlist before redirecting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After a permanent URL change

  • Update menus, content links, XML sitemaps and canonical references to the new URL.
  • Keep the old URL redirect in place while external links and search indexes transition.
  • Review 404 reports and redirect logs for missed variants or rules that can be consolidated.
  • Remove rules only when you are confident the old address no longer needs to serve the move and no important referrers depend on it.

The Bottom Line

Use a 301 for a real permanent move, a 302 for a temporary one, and always terminate PHP redirects with exit;. Choose the Redirection plugin for maintainable, visible rule management; PHP for conditional logic; and .htaccess for Apache-level static redirects.

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.