0

Situation

I'm trying to host 2 Wordpress websites on the same virtual machine.

  • Site1: www.mainsite.com
  • Site2: site2.mainsite.com

Each site has its own Wordpress installation and database (not multisite).

Environment

  • Ubuntu 18.04
  • Nginx 1.17.1
  • PHP7.3-FPM
  • Certbot for Let's Encrypt
  • HSTS activated for domain

Problem

After installing both Wordpress websites and logging in on wp-admin. The last one starts redirecting to the other one with a 301 redirect.

Steps to reproduce:

  • Clear browser cache
  • Visit www.mainsite.com/wp-admin and login
  • Visit site2.mainsite.com/wp-admin and login
  • Visit www.mainsite.com
  • Visit site2.mainsite.com -> Gets redirected to www.mainsite.com with X-Redirect-By: WordPress in the response header

This is not always true, sometimes it works for a few minutes before it starts to redirect. The 301 redirects get cached by the browser, so when the redirect occurs, it never works again unless I manually clear my browser cache.

Tried solutions

  • Clearing browser cache, tried another computer
  • Added WP_HOME and WP_SITEURL to both wp-config.php files
  • Checked my Nginx server blocks and PHP-pools
  • Tried separate SSL certificates with Certbot
  • Tried wildcard SSL certificate with Certbot
  • Reboot
  • Checked both MySQL databases for URLS

Do I have to add something in the Wordpress config to stop the redirect? I think it has something to do with the cookie that got created when logging in.

1
  • Just a comment, but it sounds like the potential solution here is to log out of one site before logging in to the other. Commented Jul 23, 2019 at 5:12

1 Answer 1

0

It seems, you have not set opcache.validate_root=1 in php.ini. It's mandatory for chrooted php-fpm with multiple pools (and unfortunately not very clearly documented).

RTFM: https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.validate-root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.