How to Set Up Redirects in WordPress
Complete guide to WordPress redirects: plugin options (Redirection, Yoast, Rank Math), manual .htaccess methods, wp-config redirects, regex patterns, and troubleshooting common issues.
WordPress does not have a built-in redirect manager. When you change a page's slug, WordPress does not automatically redirect the old URL. The old URL just 404s. You need to handle redirects yourself, either through a plugin or manual configuration. For the full overview of all redirect types, see our HTTP Redirect Guide.
This guide covers every method available, from beginner-friendly plugins to manual .htaccess rules, along with the WordPress-specific issues that catch people off guard.
Plugin Options
Plugins are the easiest way to manage redirects in WordPress. They provide a UI for adding, editing, and monitoring redirects without touching server config files.
Redirection (Free)
The most popular dedicated redirect plugin. Over two million active installs.
What it does:
- Add individual 301, 302, 307, and 308 redirects
- Regex support for pattern-based redirects
- Automatic logging of 404 errors so you can spot missing redirects
- Import/export redirects via CSV or JSON
- Conditional redirects (by login status, referrer, cookie)
- Monitor redirect hits and last-accessed dates
Setup:
- Install and activate from Plugins > Add New
- Go to Tools > Redirection
- Run the setup wizard (creates database tables and optionally installs Apache/Nginx integration)
- Add redirects one by one or import a list
The Redirection plugin stores its rules in the WordPress database by default. This means every redirect requires a database query on page load. For sites with hundreds of redirects, this adds overhead. The plugin offers an Apache or Nginx option that writes rules to config files for better performance, but most sites will not notice the difference unless they have thousands of redirects.
Yoast SEO Premium
Yoast Premium includes a redirect manager as part of its SEO suite. It is not a standalone redirect plugin.
What it does:
- Detects when you change a URL slug and prompts you to create a redirect
- Detects deleted posts and prompts for a redirect
- Simple UI for adding 301 and 302 redirects
- Regex support
- No 404 monitoring (you need the free Yoast plugin's integration with Google Search Console for that)
Yoast's redirect manager is convenient if you already pay for Yoast Premium. It is not worth buying Yoast Premium solely for redirects. The free Redirection plugin does more.
Rank Math
Rank Math includes redirect management in its free tier.
What it does:
- 301, 302, 307, 410, and 451 redirects
- Auto-redirect when a post slug changes (if enabled)
- Regex support
- 404 monitor to find broken URLs
- Import redirects from the Redirection plugin, Yoast, and others
Rank Math stores redirects in the database. Like Redirection, performance is fine for most sites. If you already use Rank Math for SEO, its redirect manager is solid and saves you from installing another plugin.
Which plugin should you use?
- Already using Yoast Premium or Rank Math? Use their built-in redirect features. No need for a separate plugin.
- Not using a premium SEO plugin? Install the free Redirection plugin. It is purpose-built for this.
- Need something lightweight? Simple 301 Redirects or Safe Redirect Manager are minimal alternatives.
Manual .htaccess Method
If your WordPress site runs on Apache (most shared hosting does), you can add redirects directly to the .htaccess file. This bypasses WordPress entirely, which means faster execution and no database queries. For a deep dive on .htaccess syntax, see .htaccess Redirect Rules Guide.
Where is the .htaccess file?
In your WordPress root directory (the same folder as wp-config.php). WordPress already uses .htaccess for its permalink structure. You will see a block like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Adding redirects
Add your redirect rules above the WordPress block. If you put them inside the # BEGIN WordPress / # END WordPress section, WordPress may overwrite them when it updates permalink settings.
# Custom redirects (above WordPress block)
RewriteEngine On
RewriteRule ^old-post/?$ /new-post [R=301,L]
RewriteRule ^old-category/(.*)$ /new-category/$1 [R=301,L]
# BEGIN WordPress
# ... (WordPress rules)
# END WordPress
Forcing HTTPS in .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Put this above the WordPress block. For the complete HTTPS migration process, see HTTP to HTTPS Redirect Guide.
wp-config.php Redirects
For site-wide URL changes (like switching domains), you can force WordPress to use a specific URL by setting constants in wp-config.php:
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');
This overrides the values stored in the database (Settings > General). It is useful when you have migrated to a new domain and cannot access the WordPress admin because the old domain settings are causing redirect issues.
This does not create HTTP redirects. It tells WordPress which URL to use when generating links. For actual redirects from the old domain, you still need .htaccess or DNS-level rules.
Database-Level Redirects
Some redirect issues come from the WordPress database itself, specifically the siteurl and home options in the wp_options table.
Check your stored URLs
SELECT option_name, option_value FROM wp_options
WHERE option_name IN ('siteurl', 'home');
If these values do not match your actual domain (or if one is HTTP and the other HTTPS), WordPress will redirect incorrectly. Fix them:
UPDATE wp_options SET option_value = 'https://example.com'
WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'https://example.com'
WHERE option_name = 'home';
After updating, clear any caching plugins and test. Mismatched siteurl and home values are one of the top causes of redirect loops in WordPress.
Regex Redirects
Both the Redirection plugin and .htaccess support regex patterns. Here are patterns WordPress sites commonly need.
Redirect all posts from one category to another
# .htaccess
RewriteRule ^category/old-name/(.*)$ /category/new-name/$1 [R=301,L]
In the Redirection plugin: set the source to /category/old-name/(.*), enable regex, and set the target to /category/new-name/$1.
Redirect tag archives to category archives
RewriteRule ^tag/([^/]+)/?$ /category/$1 [R=301,L]
Redirect paginated URLs to the parent
RewriteRule ^(.*)/page/[0-9]+/?$ /$1 [R=301,L]
Strip date from permalink structure
If you changed from /2024/03/post-name/ to /post-name/:
RewriteRule ^[0-9]{4}/[0-9]{2}/(.*)$ /$1 [R=301,L]
Monitoring Redirect Health
Setting up redirects is half the job. The other half is making sure they keep working.
What to monitor
- 404 errors: New 404s often mean a missing redirect. The Redirection plugin logs these automatically. Google Search Console also reports crawl errors.
- Redirect chains: A redirect that points to another redirect that points to another redirect. Each hop costs load time and dilutes SEO value. See Redirect Chains Explained for details.
- Redirect response time: A redirect should add minimal latency. If a redirect takes seconds instead of milliseconds, something is wrong (usually a plugin conflict or database issue).
- Cached redirects: Browsers cache 301 redirects aggressively. If you change a redirect and users still see the old destination, the browser cache is the likely cause.
Periodic audits
Run a redirect audit quarterly, or after any significant site change:
- Export your redirect list (from plugin or .htaccess)
- Test each redirect to verify it still reaches the correct destination
- Check for redirect chains (A redirects to B redirects to C)
- Remove redirects for URLs that no longer receive traffic
- Check Google Search Console for new crawl errors
Common WordPress Redirect Issues
The redirect loop after changing site URL
You changed the URL in Settings > General (or in the database), and now the site is stuck in a redirect loop. The fix:
- Add
WP_HOMEandWP_SITEURLconstants towp-config.phpwith the correct URL - If that does not work, check
.htaccessfor conflicting redirect rules - Disable all plugins via FTP (rename the
pluginsfolder) to rule out plugin conflicts
Mixed HTTP/HTTPS in WordPress
WordPress stores absolute URLs in the database (in post content, options, and metadata). If you migrated to HTTPS but the database still contains http:// URLs, WordPress may generate mixed content or redirect oddly.
Fix it with a search-and-replace tool like Better Search Replace or WP-CLI:
wp search-replace 'http://example.com' 'https://example.com' --all-tables
Plugin conflicts
Multiple plugins trying to handle redirects can conflict. If you use Yoast Premium's redirect manager, do not also install the Redirection plugin for the same URLs. Pick one system and use it consistently.
Caching plugin interference
Caching plugins (WP Super Cache, W3 Total Cache, WP Rocket) can cache redirect responses. If you change a redirect and it does not take effect, clear the cache. Some caching plugins also need to be configured to exclude redirected URLs from caching.
Test redirects in incognito mode
Browsers cache 301 redirects locally. When testing, always use an incognito/private window or curl. Otherwise you are testing the browser's cached version, not the actual server response.
Performance Considerations
Plugin-based redirects run through WordPress's PHP stack on every request. The process: web server receives request, passes it to PHP, WordPress loads, the redirect plugin checks the database, and then returns a 301. That is a lot of work for a redirect.
For sites with a handful of redirects, this is fine. For sites with hundreds or thousands of redirects, consider:
- Using the Redirection plugin's Apache/Nginx module (writes rules to server config)
- Moving high-traffic redirects to
.htaccesswhere they execute before WordPress loads - Using server-level redirects (Nginx config or Apache VirtualHost) for domain-wide rules like HTTPS enforcement
Server-level redirects execute in microseconds. Plugin-based redirects take tens or hundreds of milliseconds. At scale, the difference matters.
Trace your redirect chains
Check any URL for redirect chains, loops, and broken hops.
References
- WordPress.org, "Redirection Plugin," https://wordpress.org/plugins/redirection/
- WordPress Developer Resources, "Rewrite API," https://developer.wordpress.org/apis/rewrite/
- Yoast, "Redirect Manager," https://yoast.com/help/redirect-manager/
Related Articles
Never miss a broken redirect
Trace redirect chains and detect issues before they affect your users and SEO. Free instant tracing.
Try Redirect Tracer