Bedrock, multisite and https://https//xxxxx.com

Hi there,

I have a problem with the multisite website setup. I’m using a subdomain. I use Local Flywheel as a development environment.

Issue: Website works more or less fine, but I can not access the Network Admin area:
I got redirected to the https://http//xxxxx.local/wp-admin/network/sites.php:

This is my application.php file (part of it):
/* Multisite */
define(‘WP_ALLOW_MULTISITE’, true);
define(‘MULTISITE’, true);
define(‘SUBDOMAIN_INSTALL’, true); // Set to true if using subdomains
define(‘DOMAIN_CURRENT_SITE’, env(‘WP_HOME’));
define(‘PATH_CURRENT_SITE’, ‘/’);
define(‘SITE_ID_CURRENT_SITE’, env(‘SITE_ID_CURRENT_SITE’) ?: 1);
define(‘BLOG_ID_CURRENT_SITE’, env(‘BLOG_ID_CURRENT_SITE’) ?: 1);

My .env file (part of it):
DB_NAME=local
DB_USER=root
DB_PASSWORD=root

WP_ENV=development
WP_HOME=https://xxxxxx.local
WP_SITEURL=${WP_HOME}/wp

My site.conf file (part of it):
server {
root /app/web/;

    # special config for Bedrock + Multisite
    if (!-e $request_filename) {
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
      rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
      rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
    }

    index index.php index.html index.htm;

I’m not sure where to dig in to fix the issue with https://http//. The rest of the website works fine.

Could anyone help me with this? Or point me in the direction where I can get some solution?

Cheers,
Vladimir

Hey there Vladimir,

I use Bedrock + Local + Multisite, so hopefully I can help you here…

Do you have DOMAIN_CURRENT_SITE defined in your .env?

This is what my basic .env looks like:

DOMAIN_CURRENT_SITE='xxx.local'
WP_ENV='development'
WP_HOME='https://xxx.local'
WP_SITEURL='https://xxx.local/wp'

I also didn’t need to add any special configs to Local for multisite other than selecting “Multisite > Yes” and “subdomain”, and changing the webroot when I created the site. See https://roots.io/guides/local-bedrock-development-with-local-by-flywheel/ if you haven’t already.

Let us know how it goes!

1 Like

Hey Julien,

Thank you for your reply. Yes, indeed, I don’t have the DOMAIN_CURRENT_SITE in .env file,
however, it is set in application php, so it is basically the same as in .env:
/* Multisite */
define(‘WP_ALLOW_MULTISITE’, true);
define(‘MULTISITE’, true);
define(‘SUBDOMAIN_INSTALL’, true); // Set to true if using subdomains
define(‘DOMAIN_CURRENT_SITE’, env(‘WP_HOME’));
define(‘PATH_CURRENT_SITE’, ‘/’);
define(‘SITE_ID_CURRENT_SITE’, env(‘SITE_ID_CURRENT_SITE’) ?: 1);
define(‘BLOG_ID_CURRENT_SITE’, env(‘BLOG_ID_CURRENT_SITE’) ?: 1);

I tried to put it to .env but didn’t make any effect.

Actually double checked it by removing that part in application.php file and adding it to .env and it worked! Yay, thanks a lot!!!

Hey Julien,

One more thing you might know.

When I create the “main” website https://xxxxx.local, Local edits the hosts file adding there the:
192.168.75.100 xxxxx.local #Local Site
192.168.75.100 www.xxxxx.local #Local Site

In order to make second site work as a subdomain, I have to edit hosts file, manually adding the links for th subdomain:
192.168.75.100 subdomain.xxxxx.local #Local Site
192.168.75.100 www.subdomain.xxxxx.local #Local Site

Every time I restart the project in local, the hosts file is getting refreshed and these two lines disappearing. Do you know how to make it the way the links are always there?

Personally, I just click past the annoying warnings and I don’t let Local modify my hosts file. I think they should probably just have an option for those who want to manage their own hosts file.

Gas Mask is what I have used in the past. It detects applications trying to make changes to the hosts file, so that has always worked for me ¯\(ツ)

Glad you got it figured out!

Hostile is a nice cross platform alternative to Gas Mask.

1 Like

Thank you for help here :slight_smile:

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.