Back to DevLog

Fighting WordPress Redirect Loops While Scaling Across 7 Verticals

3 min read

Had one of those sessions where everything goes right until it doesn't. Been working on scaling our booking system across different service verticals, and today was all about getting domain mapping sorted for 7 different industries.

The Good Stuff

Got through a solid chunk of infrastructure work today. Rewrote all the homepage templates for 6 verticals (plumber, gym, HVAC, medspa, realtor, roofer) to remove any photo booth references - these are completely different businesses now. Deployed everything via rsync, which always feels satisfying when it just works.

The domain setup went smoother than expected. Registered aliases for all 7 verticals through the Cloudways API, updated WordPress options via direct MySQL (wp-cli wasn't available to the master user), and injected the proper constants into wp-config files. Even switched Cloudflare to proxied mode for wildcard SSL - way easier than dealing with Let's Encrypt for each domain.

Then Reality Hit

Of course, there's always that one thing that breaks. The plumber subdomain is stuck in a redirect loop, bouncing from plumber.gethoneybun.com back to the staging domain. Got the dreaded x-redirect-by: WordPress header, which is WordPress being "helpful" with canonical redirects.

Weird part is that when I test home_url() and redirect_canonical() via PHP CLI, they return the correct values with no redirect. But hit it through the browser? Straight back to staging. My gut says nginx is doing something sneaky with canonical redirects for alias domains, but the nginx config is root-owned so I can't peek at it.

Debug Archaeology

Left some debug artifacts on the plumber server that need cleaning up next session:

  • A few debug PHP files I created
  • Disabled object cache and advanced cache (backed up the originals)
  • Various test scripts

Made a note to restore everything and clean up the mess I made while debugging.

Technical Decisions

Few things I learned today:

  • Using Python string replacement over SSH instead of sed - quote escaping was getting ridiculous
  • Direct MySQL for WordPress options when wp-cli isn't available
  • Cloudways' primary domain API endpoint is completely broken, so just skipping that

What's Next

Need to restore the cache plugins and clean up my debug files first. Then either dive deeper into the nginx redirect issue (might need to open a support ticket) or move on to the barbershop vertical rewrite. Still have the barbershop intake form to audit too.

Sometimes these infrastructure days feel like digital archaeology - you're never quite sure what you'll uncover when you start poking around. But hey, 6 out of 7 domains working isn't terrible for a day's work.

Share this post