admin管理员组

文章数量:1414613

Situation

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

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

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/wp-admin and login
  • Visit site2.mainsite/wp-admin and login
  • Visit www.mainsite
  • Visit site2.mainsite -> Gets redirected to www.mainsite 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.

Situation

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

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

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/wp-admin and login
  • Visit site2.mainsite/wp-admin and login
  • Visit www.mainsite
  • Visit site2.mainsite -> Gets redirected to www.mainsite 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.

Share Improve this question edited Sep 11, 2019 at 7:01 slimag 31 bronze badge asked Jul 22, 2019 at 19:10 RofniRofni 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. – Anaksunaman Commented Jul 23, 2019 at 5:12
Add a comment  | 

1 Answer 1

Reset to default 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/manual/en/opcache.configuration.php#ini.opcache.validate-root

本文标签: phpWordpress randomly redirects with 301 after logging in