Working Nginx rewrite rules for wordpress multisite 3.x WP Super Cache
-
First of all, Hi.
I got back into blogging recently and because i already switched to a LEMP stack for another project i decided to stick with it. I just spent all day long trying to set the rewrite rules correctly but 99% of the ones found on the internet simply didn’t work until i got to a really good one. Everything works as it should, subdomains work properly and media files show properly.To spare others from having to search for hours like i did i’m going to post my nginx.conf file contents here and other useful tips.
nginx.conf
server { listen 80; server_name *.domain.tld; access_log /srv/www/www.domain.tld/logs/access.log; error_log /srv/www/www.domain.tld/logs/error.log; root /srv/www/www.domain.tld/public_html; index index.html index.htm index.php; location ~ .*\.(php|php5)?$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /srv/www/www.domain.tld/public_html$fastcgi_script_name; } rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; }
Save and do a
sudo service nginx restart
to apply changes.Everything else is just like the Apache setup:
add
define('WP_DEBUG', false); define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); $base = '/'; define( 'DOMAIN_CURRENT_SITE', 'domain.tld' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 );
in your wp-config.php before the line /* That’s all, stop editing! Happy blogging. */
create the /wp-content/blogs.dir/ and set permissions to 777 ( it has to be writable )
That’s pretty much it. I will set up WP Super Cache now and post that config file as well.
- The topic ‘Working Nginx rewrite rules for wordpress multisite 3.x WP Super Cache’ is closed to new replies.