Last Updated: February 25, 2016
·
2.894K
· joegardiner

Nginx WordPress multi-site rewrite rules

Picture

There is no .htaccess file in Nginx so instead edit the nginx.conf file located here: /etc/nginx/nginx.conf

In a previous Pro Tip (http://coderwall.com/p/v65ueq) I show a standard rewrite config snippet, below is the same snippet with added support for WordPress multi-site rewrites.

When enabling a WordPress network this is what you add to your Nginx conf file instead of copying and pasting the content that WordPress suggests for an .htaccess file.

Rewrite for multi site files

rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;

Rewrite for wordpress

if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}