• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / wordpress tutorials for beginners advanced complete guide to run WordPress / nginx wordpress multisite subdirectory multiple domains

nginx wordpress multisite subdirectory multiple domains

Prepare for Multi site network

deactiavate plugins it will also asks later.

 

First enable WordPress multisite on website

Table of Contents

Toggle
  • Step 2: Allow Multisite
  • Step 3: Network setup
  • Step 4: Enabling the Network
  • Nginx config for Sub-directories for domain named example.com:
  • Step 3: Installing a Network
  • nginx wordpress multisite subdirectory settings

Step 2: Allow Multisite

Edit the wp-config.php file:

nano /usr/share/nginx/wordpress/wp-config.php

0r

nano /var/www/html/southjobs.in/wp-config.php
Add the following code before the comment /* That’s all, stop editing! Happy blogging. */:

/* Multisite settings */
define( ‘WP_ALLOW_MULTISITE’, true );

Step 3: Network setup

The previous step enables the Network Setup item in your Tools menu. Use that menu item to go to the Create a Network of WordPress Sites screen.

Create a Network of WordPress Sites page

Step 4: Enabling the Network

Populated settings when creating a network of sites

Nginx config for Sub-directories for domain named example.com:

server {
listen [::]:80 ipv6only=off;
server_name examplewp.com *.examplewp.com shoppingsite.com companysite.org;

root /usr/share/nginx/wordpress;

rewriting wp-admin site.com/musite/wp-admin

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;

if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}

# Rewrite multisite ‘…/wp-.*’ and ‘…/*.php’.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;

}

or

 

server {
        ##DM - uncomment following line for domain mapping	
        #listen 80 default_server;
	server_name example.com *.example.com ;
	##DM - uncomment following line for domain mapping
	#server_name_in_redirect off;

	

	root /var/www/example.com/htdocs;
	index index.php;

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

	location / {
		try_files $uri $uri/ /index.php?$args ;
	}

	location ~ .php$ {
		try_files $uri =404;
		include fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
	}

	
}

https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

https://wordpress.org/documentation/article/create-a-network/

nginx -t && nginx -s reload

 

Step 3: Installing a Network

Administration >Tools > Network Setup.

 

Sub-domain Installation Because your installation is not new, the sites in your WordPress network must use sub-domains. The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.

bypassing sub domain define(‘ALLOW_SUBDIRECTORY_INSTALL’, true);

define( ‘MULTISITE’, true );

define( ‘SUBDOMAIN_INSTALL’, false );
define( ‘DOMAIN_CURRENT_SITE’, ‘southjobs.in’ );
define( ‘PATH_CURRENT_SITE’, ‘/’ );
define( ‘SITE_ID_CURRENT_SITE’, 1 );
define( ‘BLOG_ID_CURRENT_SITE’, 1 );

if changes not reflected restart php fpm  service php8.1-fpm restart to clear opcode cache or opcache

 

https://wordpress.org/documentation/article/nginx/

 

/wp-admin/network/sites.php

 

Create new site

nginx wordpress multisite subdirectory settings

root /var/www/example.com/htdocs;

index index.php;

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

or

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


final file

server {
        server_name example.com ;

        access_log   /var/log/nginx/example.com.access.log;
        error_log    /var/log/nginx/example.com.error.log debug;

        root /var/www/example.com/htdocs ;
        index index.php;

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

        location / {
                try_files $uri $uri/ /wordpress/index.php?$args ;
        }

        location ~ \.php$ {
                try_files $uri /wordpress/index.php;
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
        }
}

3rd way

# WordPress Multisite Subdirectory
if (!-e $request_filename) {
rewrite /wp-admin$ https://$host$uri permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

if (-f $request_filename) {
break;
}

Primary Sidebar

wordpress tutorials for beginners advanced complete guide to run WordPress

  • wordpress speed optimization Speed up wordpress Score on Google pagespeed
  • best wordpress plugins social, seo, Backup, speed up your blog
  • TOP 10 Wordpress Themes Premium/ Free & providers
  • Wordpress Adsense Plugins & Manually
  • Social share buttons for website Wordpress Blogger
  • How to bulk delete in wordpress posts, pages, Media Images, tags and categories
  • TOP 5 Best wordpress comment plugins 2020 (disable pingback, replytocom, customize form)
  • all in one seo pack vs yoast seo pressor
  • Auto post to Facebook, twitter, Google Plus Wordpress Posts 2019
  • wordpress plugins that slow down your site and its alternatives
  • How to use wordpress tags and categories
  • Wordpress duplicate thin content Issues {FIXED}
  • how to increase wordpress memory & file upload size
  • combine rss feeds wordpress
  • Reduce the impact of third-party code ,optimize JS delivery, Minify, remove unused js, pre connect, inline, lazy load etc
  • change wordpress site url internal links in mysql command phpmyadmin
  • install wordpress on ubuntu nginx lemp command line apache debian
  • Wordpress Security Plugins 2021 (Brute force, Login lockdown, Malware scanner etc)
  • website cache best caching plugins wordpress w3tc cloudflare
  • How to add adsense amp ads to wordpress
  • wordpress password reset in 3 ways mail, phpmyadmin, mysql command
  • how i recovered hacked website site 5 times ft wordpress?
  • wordpress redirection examples Rankmath seo
  • enable browser caching in wordpress apache nginx caching headers explained
  • W3TC w3 total cache plugin setup guide review comparison with wp rocket and wp super cache
  • Wordpress database optimization (don't neglect) plugins & phpmyadmin manually
  • Optimize css delivery inline critical css, remove unused css, render blocking css
  • Converting WordPress into static website speed after 1 second dynamic 3 seconds
  • Wordpress errors and fix
  • Rules to get 100/100 in Google pagespeed web core vitalsscore
  • Install xamp & wordpress on localhost windows
  • favicon ico Change / Add / Disable favicon in wordpress Ft Genesis Theme or any theme
  • increase wordpress memory limit (how to ) 40MB , 64 MB 128 MB or 512 MB maybe 1024MB
  • wp cron job check working or not disable enable change schedule
  • google analytics plugins for wordpress #sitekit #monsterinsights gadwp back as gainwp
  • Lazy Load Adsense to improve core web vitals - Vs revenue
  • xmlrpc php wordpress uses, disable without 403 error log message
  • wordpress 304 header implement using plugin
  • wordpress change post date programmatically (auto on update like blogger
  • sorry you are not allowed to access this page. admin WordPress options table
  • clone wordpress in linux ubuntu server lemp nginx
  • Cloudflare cache rules for WordPress along with page rules cache level everything
  • wordfence-waf.php fatal error fixed after migration
  • Cloudflare page rules cache level everything redirect and sub domain
  • wordpress delete all posts from database mysql query for phpmyadmin
  • php fpm oom killer problem how to dig it.. memory pool and execution time
  • nginx wordpress multisite subdirectory multiple domains
  • Helpful Content update recovery Trying to dig it
  • How to Move a Single WordPress Site into a Multisite
  • Enable multisite in wordpress in 3 steps problems datbase error
  • Seprate single site from wordpress multisite domain based
  • Error establishing a database connection wordpress multisite
  • Add single wordpress to MultiSite wordpress
  • genesis theme cateogory customization examples
  • could not insert term into the database. wordpress
  • wordpress breadcrumbs not showing full path
  • There has been a critical error on this website fed up
  • Site structure WP categories vs sub pages or multisite posts or pages
  • WordPress pyramid structure Permalinks Category vs sub pages vs multisite

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy