I’m trying to move an existing Bedrock based multisite instance to nginx and am having difficulty getting a set of nginx rules to mimic the original .htaccess. Bedrock places the crux of the files in a wp/ subdirectory, but the urls still need to be accessible from the root domain.
The .htaccess is here as follows:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*.php)$ wp/$1 [L]
RewriteRule . index.php [L]
I need these at least as nginx conf rules or preferably nginx vhost rules.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Ok some wise guy deleted my last post.
The answer, which the above member (@etc) gave to me on another forum, and is working quite fine, is as follows:
# Rewrites for Bedrock Multi-Site Subdomain Setup rewrite /wp-admin$ $scheme://$host$uri/ last; rewrite ^/(wp-.*.php)$ /wp/$1 last; rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
He revised his answer but did not post it back here. I simply wanted to update it as I ran across this thread as well.
Method 2
rewrite /wp-admin$ $scheme://$host$uri/ last; rewrite ^/(wp-.*.php)$ /wp/$1 last; rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
These are the equivalent rewrite rules that you need. Note, when you use this rewrite, you no longer have to set the site_url as /wp
I need to finish up some testing but will update here with the results.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0