One Site To Rule Them All

I’ve spent a good chunk of time this week transitioning AFdN from a standalone WordPress site to be part of the ferguson.pw WordPress Multisite cluster.

This is more cool for me than you because I now only have to manage one WordPress installation for everyone, rather than two or more installations. Huzzah!

Some lessons learned:

  • Multisite cookies are the suck. Towards the end of the migration I ran into an issue where draft post previews were not working. I started running through my checklist of things that could be the cause, but nothing made sense. I eventually created a new user — notandrew — to see it was an issue limited my “super-administrator” capabilities and to my surprise notandrew could see the previews just fine. So I nuked all cookies for ferguson.pw domain and lo and behold everything worked.
  • When migrating a Standalone WordPress site to a Multisite and mapping the domain back to the original URL you can use the following Nginx rewrite to prevent breaking anything1:
            #rewrite for WordPress single site to multisite
            location /wp-content/uploads/ {
                    rewrite "^(/wp-content/uploads)/([0-9]{4}/[0-9]{2}/.*)" $1/sites/$blogid/$2;
            }

    Note: this is also predicated on using the Nginx Map{..} directive.

  • There’s a long standing bug with Nginx regarding the use of alias versus root. In the end I was able to use alias2 to host a special directory for TweetNest. Here’s the solution I ultimately arrived at:
            location /tweetnest {
                    alias /path/to/example.com/html/tweetnest;
    
                    rewrite  ^/tweetnest/sort /tweetnest/sort.php;
                    rewrite  ^/tweetnest/favorites /tweetnest/favorites.php;
                    rewrite  ^/tweetnest/search /tweetnest/search.php;
                    rewrite  ^/tweetnest/([0-9]+)/([0-9]+)/([0-9]+)? /tweetnest/day.php?y=$1&m=$2&d=$3;
                    rewrite  ^/tweetnest/([0-9]+)/([0-9]+)? /tweetnest/month.php?y=$1&m=$2;
    
    
                    location ~ \.php$ {
                            fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
                            fastcgi_pass unix:/var/run/php5-fpm.sock;
                            fastcgi_index index.php;
                            include /etc/nginx/fastcgi_params;
                    }
    
            }
    

I also took the opportunity to clear out some cruft and update some look and feel stuff: redish/orangish theme, update profile, etc. Nothing should be broken, but you never know. Enjoy your weekend.


  1. in theory 

  2. which I believe is the correct way 

7ads6x98y