Nginx config for WP Multisite (subdomain) with WP in its own directory
-
Hey there,
My question is about the nginx config for a WP multisite (subdomain) install.
I first did a single site install with WP located in its own directory (as in Mark Jaquith’s WordPress Skeleton). My nginx config looks like this:
location / { try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; # Directives to send expires headers and turn off 404 error logging. location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } # Pass all .php files onto a php-fpm/php-fcgi server. location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_keep_conn on; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; }
I then proceeded to setup a multisite network as described in the codex. At the end of the process, WordPress gave me a bunch of code to insert into
wp-config.php
define('MULTISITE', true); define('SUBDOMAIN_INSTALL', true); define('DOMAIN_CURRENT_SITE', 'example.com'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1);
and a
.htaccess
fileRewriteEngine 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 am having a little trouble converting this to nginx config. Here is my best attempt so far:
location / { try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; # Redirect wp-(content|admin|includes) to wp/wp-(content|admin|includes) rewrite ^/(wp-(content|admin|includes).*) /wp/$1 break; # Directives to send expires headers and turn off 404 error logging. location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } # Pass all .php files onto a php-fpm/php-fcgi server. location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_keep_conn on; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; }
With this config, WP correctly sets the network admin URL to example.com/wp-admin/network. However, the admin URL for the main site is still example.com/wp/wp-admin (I think it should be example.com/wp-admin). Anyone know how I can fix this? Also, is the rest of the config right or have I missed something?
Thanks!
Joe
- The topic ‘Nginx config for WP Multisite (subdomain) with WP in its own directory’ is closed to new replies.