Article

How to Redirect WordPress URLs Without a Plugin

How to Redirect URLs in WordPress Without a Plugin

You can redirect an old WordPress URL to its replacement using hosting controls, an Apache rewrite rule, or WordPress PHP. Choose the method that fits your server and the number of redirects you need to maintain.

Use a permanent redirect for a genuinely permanent move. During testing, a temporary redirect can avoid sticky browser caching. A redirect helps users and search engines find the replacement, but does not guarantee unchanged rankings.

Plan the source and destination

Map each old URL to the closest relevant replacement. Do not redirect every missing page to the homepage. Confirm the destination works, remove unnecessary intermediate redirects, and update internal links to point directly to the final URL.

Method 1: An exact Apache rewrite

This example is for an Apache-compatible server with rewriting enabled and a root-level WordPress installation. Back up .htaccess first. Put your custom rules outside and before the WordPress-managed section so saving permalinks does not overwrite them.

# Exact old-page redirect
RewriteEngine On
RewriteRule ^old-page/?$ https://example.com/new-page/ [R=301,L]

# BEGIN WordPress
# Keep the existing WordPress rules below this point.

Replace both example paths and the domain. The anchored pattern matches the old page with or without its trailing slash, rather than every path starting with the same text. Apache normally retains the original query string when the replacement has none; decide whether that is appropriate for your URLs.

For subdirectory installations or Nginx hosting, do not copy the root Apache example unchanged. Nginx does not use .htaccess; use your host’s redirect interface or ask for an appropriate server rule.

Method 2: A WordPress page redirect

For an existing WordPress page, add this PHP to the child theme’s functions.php. It uses the old page’s slug and redirects to a local destination.

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

Do not add a second PHP opening tag inside an existing PHP file. This page-condition method requires the old page to resolve as a page; it will not match an already deleted page by slug. It also depends on the active child theme. Use hosting-level rules or a maintained redirect system for a large migration.

Test the response, not just the destination

curl -I https://example.com/old-page/

Confirm the source returns the intended redirect status and Location header. Then confirm the destination returns the expected successful response. Check the trailing slash, query strings, and a similarly named path that should not redirect. Use GET-based tools if your host handles HEAD requests differently.

Avoid common mistakes

  • Redirecting a destination back to its source.
  • Creating chains across several old addresses.
  • Mixing HTTPS and www rules across the CDN, host, and WordPress.
  • Testing only in a browser that has cached an earlier 301.
  • Putting a redirect on the same line as an Apache comment, which comments it out.

For larger moves, use the website migration SEO checklist. References: Apache rewrite documentation and WordPress wp_safe_redirect.

Need help implementing this?

Explore my WordPress development services or send your website URL and requirements for a scoped implementation and verification.

Need help fixing this on your website?

Need help fixing this on your website? Chat with me on WhatsApp.

Explore relevant services

Chat on WhatsApp

Need help with a website project?

Chat on WhatsApp