WooCommerce redirects: Implementation, management, and troubleshooting
Redirects in WooCommerce are critical for proper site navigation, user experience, and SEO performance. When implemented correctly, they guide customers seamlessly through your store while maintaining search engine rankings. When done poorly, they create frustrating loops, broken customer journeys, and lost sales.
I’ve seen countless WooCommerce stores struggle with redirect issues that silently damage their conversion rates. Let’s fix that by covering everything store owners and developers need to know about WooCommerce redirects.
Types of redirects in WooCommerce
WooCommerce relies on several types of redirects, each serving specific purposes:
HTTP status code redirects
- 301 (Permanent): The gold standard when permanently moving content. Transfers SEO equity to the new URL.
- 302 (Temporary): Use when temporarily redirecting traffic while preserving the original page’s SEO value.
- 307 (Temporary): Similar to 302 but maintains the original HTTP method (GET remains GET, POST remains POST).
- 308 (Permanent): Like 301 but preserves the HTTP method when redirecting.
WooCommerce-specific redirects
- Login redirects: Where users go after logging in
- Registration redirects: Where new customers land after creating an account
- Logout redirects: Where customers go after signing out
- Add-to-cart redirects: Whether to send users to the cart page or keep them on the product page
- Checkout redirects: Where to send customers after completing a purchase
- Empty cart redirects: Where to direct customers when they have an empty cart
Setting up basic WooCommerce redirects
Login, registration, and logout redirects
WooCommerce offers built-in options for these redirects under WooCommerce → Settings → Advanced → Account. Here you can specify:
- Where to send customers after login (default is “My Account”)
- Where to direct new registrations (default is “My Account”)
- Where to send customers after logout (default is the homepage)
For more advanced customization, use filter hooks:
// Custom login redirectadd_filter('woocommerce_login_redirect', 'custom_login_redirect', 10, 2);function custom_login_redirect($redirect, $user) { // Example: redirect to shop page return wc_get_page_permalink('shop');}
Add-to-cart redirects
By default, WooCommerce keeps customers on the product page after adding items to cart. To change this:
- Navigate to WooCommerce → Settings → Products → General
- Find “Add to cart behavior”
- Choose between “Stay on page” or “Redirect to cart”
For product-specific redirects, use this filter:
add_filter('woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect');function custom_add_to_cart_redirect() { // Redirect to checkout instead of cart return wc_get_checkout_url();}
Post-checkout redirects
To redirect customers after checkout to a custom thank you page:
add_action('template_redirect', 'custom_checkout_redirect');function custom_checkout_redirect() { if (is_order_received_page()) { wp_redirect('https://yourstore.com/custom-thank-you/'); exit(); }}
Remember: Always include exit()
after a wp_redirect()
to prevent further code execution.
Implementing site-wide redirect strategies
Using .htaccess (Apache servers)
For permanent redirects on Apache servers, add to your .htaccess file:
Redirect 301 /old-page /new-pageRedirectMatch 301 ^/old-category/(.*)$ /new-category/$1
Using WordPress plugins
Several plugins simplify redirect management:
- Redirection: Free plugin with robust logging and regex support
- Yoast SEO Premium: Includes redirect manager with automatic suggestions
- Rank Math: Free SEO plugin with redirect capabilities
- WP 301 Redirects: Simple, lightweight redirect manager
When choosing a plugin, consider:
- Redirect volume (some handle thousands better than others)
- Need for regex support
- Logging capabilities
- Performance impact
Programmatic redirects in WordPress/WooCommerce
For developers, implement redirects programmatically:
// Basic WordPress redirectfunction programmatic_redirect() { if (is_page('old-page')) { wp_redirect('https://yourstore.com/new-page/', 301); exit(); }}add_action('template_redirect', 'programmatic_redirect');
For PHP-level redirects (when WordPress functions aren’t available):
<?phpheader("HTTP/1.1 301 Moved Permanently");header("Location: https://yourstore.com/new-page/");exit();?>
Critical: Place this code at the very top of your PHP file before any output is sent.
Common redirect pitfalls and how to fix them
Redirect loops
Symptoms: Browser shows “too many redirects” error.
Fixes:
- Check for conflicting plugins redirecting the same URL
- Ensure you’re not redirecting to a URL that then redirects back
- Temporarily disable all redirects to identify the culprit
Login/registration redirect loops
Symptoms: Users can’t log in or register due to endless redirection.
Fix:
// Break login redirect loopsadd_filter('login_redirect', 'fix_login_redirect_loop', 99, 3);function fix_login_redirect_loop($redirect_to, $requested_redirect_to, $user) { // Check if redirect is creating a loop if (strpos($redirect_to, 'wp-login.php') !== false) { return home_url(); } return $redirect_to;}
Cached redirects
Symptoms: Redirects continue working even after you’ve removed them.
Fixes:
- Clear your site cache
- Clear your browser cache
- Check for server-level caching (talk to your host)
Plugin conflicts
Symptoms: Redirects work intermittently or stop working after installing new plugins.
Fix: Disable plugins one by one to identify conflicts.
SEO implications of redirects
Redirects significantly impact your store’s SEO performance:
Best practices
- Use 301s for permanent changes: Tells search engines to transfer link equity
- Minimize redirect chains: Each hop loses some SEO value (A→B→C is worse than A→C)
- Redirect to equivalent content: Maintain topical relevance between old and new pages
- Create a redirect plan before migrations: Document all URLs requiring redirects before switching platforms or redesigning
Common SEO redirect mistakes
- Using 302s for permanent changes: Signals to search engines this is temporary
- Redirecting all old pages to homepage: Creates poor user experience and dilutes SEO value
- Not redirecting product variations: Each variant URL needs proper redirection
- Forgetting query parameters: Parameters like
?color=blue
need appropriate handling
Using ContentGecko with WooCommerce redirects
When implementing ContentGecko’s automated SEO content strategy with WooCommerce, proper redirect handling becomes even more critical:
-
Catalog sync: ContentGecko automatically updates content when product URLs change, but properly redirecting old URLs ensures you don’t lose ranking signals during catalog restructuring. Use the free keyword clustering tool to identify groups of keywords that should point to the same content.
-
Content migration: When moving from manually-created content to ContentGecko’s automated system, implement proper 301 redirects from old blog posts to new content to preserve SEO equity.
-
URL structure optimization: ContentGecko helps optimize your content structure for both users and search engines. Calculate the potential ROI of this optimization using the SEO ROI calculator.
-
Content redirects during updates: When ContentGecko updates content to reflect catalog changes, ensure proper redirects are in place if URL structures change.
Advanced redirect techniques
Conditional redirects based on user roles
add_action('template_redirect', 'role_based_redirects');function role_based_redirects() { if (is_page('wholesale') && !current_user_can('wholesale_customer')) { wp_redirect(home_url('/apply-for-wholesale/')); exit(); }}
Geo-based redirects
add_action('template_redirect', 'geo_redirects');function geo_redirects() { // Requires IP geolocation service $country_code = get_visitor_country();
if (is_product() && $country_code == 'CA' && !is_page('shipping-restrictions')) { wp_redirect(home_url('/shipping-restrictions/')); exit(); }}
Time-limited redirects
add_action('template_redirect', 'sale_redirects');function sale_redirects() { $sale_start = strtotime('2023-11-24 00:00:00'); // Black Friday $sale_end = strtotime('2023-11-28 23:59:59'); // Cyber Monday $current_time = current_time('timestamp');
if ($current_time >= $sale_start && $current_time <= $sale_end) { if (is_front_page()) { wp_redirect(home_url('/black-friday-sale/')); exit(); } }}
Troubleshooting redirect issues
Diagnostic tools
- Redirect Checker: Use online tools like httpstatus.io to trace redirect chains
- Browser Developer Tools: Check Network tab for redirect status codes
- Redirect Mapper: Plugins like Redirection provide logs of triggered redirects
Step-by-step debugging process
- Identify the problem URL: Note the exact URL causing issues
- Check for plugin conflicts: Disable redirect plugins one by one
- Check .htaccess: Look for conflicting redirect rules
- Inspect theme functions.php: Search for hardcoded redirects
- Check WordPress hooks: Multiple plugins might use ‘template_redirect’
- Test in incognito mode: Eliminates browser caching issues
- Check server logs: May reveal redirect errors not visible in browser
Performance considerations
Excessive redirects slow down your site and hurt conversion rates:
- Each redirect adds 200-300ms of load time
- Mobile users are especially impacted by redirect delays
- Google considers page speed when ranking sites
Use the website content generator from ContentGecko to create optimized landing pages that reduce the need for redirects in the first place.
TL;DR
Proper redirect management is essential for WooCommerce stores to maintain SEO value, provide smooth user experiences, and maximize conversions. Use 301 redirects for permanent changes, implement proper login/registration/cart redirects, and regularly audit your site for redirect issues. Consider tools like ContentGecko to automate content creation while maintaining proper URL structures. Always test redirects thoroughly before implementing them on production, and monitor analytics for unexpected traffic patterns that might indicate redirect problems.