Question
Nginx setup: Wordpress installation in root + Wordpress Multisite installation in subfolder?
First off, I just setup a debian server with LEMP.
I have a very special setup, which is one Wordpress installation in the root folder, and a Wordpress Multisite network which is installed in a subfolder called “/u”.
The multisite network is served on subfolders too, not subdomains.
The current server is using Apache, which is setup this way.
Main (single site, in root):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect /login /u/login
Redirect /register /u/register
Redirect /link /u/link
Redirect /link-tv /u/link-tv
Redirect /wp-login.php /u/wp-login.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Multisite (subdir network, install in “/u”)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /u/
RewriteRule ^(([_0-9a-zA-Z-]+/)?)postpass/?$ /u/wp-login.php?action=postpass [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)logout/?$ /u/wp-login.php?action=logout [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)lostpassword/?$ /u/wp-login.php?action=lostpassword [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)resetpassword/?$ /u/wp-login.php?action=resetpass [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)signup/?$ /u/wp-login.php?action=register [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)login/?$ /u/wp-login.php [QSA,L]
RewriteRule ^(([_0-9a-zA-Z-]+/)?)dashboard/?$ /u/wp-login.php [QSA,L]
</IfModule>
RewriteEngine On
RewriteBase /u
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
This Apache setup works great, but how do I convert this to work on Nginx?
All help is appreciated!
Thanks!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×