- Edited
Three step to mapping domain without plugin:
1# Step
I prefer to have the ability to implement separate conf blocks under separate domains, it keeps things less sloppy and more organized.
Here’s what you do to implement it this way:
Create your initial site. Then, to add another that uses the same root directory run:
wo site create second-site.com --php
Note: it has to be --php so that the index.php file Wordpress creates is looked for by NginX - otherwise it will look for an index.html. Now just go to the .conf for the domain you just added - /etc/nginx/sites-available/second-site.com, open it and edit this line from:
root /var/www/second-site.com/htdocs;
And change it to:
root /var/www/first-site.com/htdocs;
Restart NginX for the changes to take effect and you’re done. It takes less than a minute and is super easy to do. IMO, far quicker and more maintainable than hacking the default conf file.
2# Step
Wo site update second-site.com --le
3#Edit wp-config.php
Check this wordpress official document
https://wordpress.org/support/article/wordpress-multisite-domain-mapping/
If you get an error about cookies being blocked when you try to log in to your network subsite (or log in fails with no error message), open your wp-config.php file and add this line after the other code you added to create the network:
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
and set second-domain on subsite by editing site on multiste dashboard.
4# restart nginx
Done.