How to setup a Wordpress blog to work inside a subdirectory of any Ruby on Rails app Wordpress & Rails don’t usually play nice together, but for maximum search engine optimization you want your blog as a — not as a . Here’s the step-by-step guide of how we were able to get our Wordpress blog as a subdirectory of our Ruby on Rails app which is hosted on Heroku. subdirectory subdomain Example: A Ruby on Rails app hosted on Heroku: rovrproducts.com A Wordpress blog hosted on Flywheel: rovrproducts.com/blog Do it for the SEO I would still strongly urge folks to keep all content on a single subdomain. We recently were able to test this using a subdomain on Moz itself (when moving our beginner’s guide to SEO from guides.moz.com to the current URL http://moz.com/beginners-guide-to-seo). The results were astounding — rankings rose dramatically across the board for every keyword we tracked to the pages. Rand Fishkin, Co-founder of Moz.com, explains it best above ( ). In short, it makes a difference. Get your blog as a subdirectory as fast as possible, otherwise you’re not maximimzing pageviews for the content you’re putting out. full answer here big Setup Wordpress Flywheel Management: No need to add a subdomain here. The password protection helps the search engines know to only visit the blog where you want it seen. We have our Wordpress blog hosted on ( ). The support is incredible, and I highly recommend them. It’ll make the rest of this a breeze. Flywheel disclaimer: my referral link and tell them you need to setup your blog like . They’ll need to change the and _Site Address (_these fields are locked in Flywheel from users changing them). Email Flywheel rovrblog.flywheelsites.com Wordpress Address Ask for Dusty (one of the Flywheel founders who worked with us) if you run into any issues. Flyhweel will need to change the URLs inside Wordpress Admin to match the proxy address. You can absolutely host your blog outside of Flywheel, but you may have a harder time following in the guide. If you run into hiccups, I’d recommend giving a run before scrapping the idea. Flywheel Setup your Rails App Add the gem to your : rack-reverse-proxy gemfile gem 'rack-reverse-proxy', :require => 'rack/reverse_proxy' Add the reverse_proxy code in your file so that /blog/ points to your blog on Flywheel. config.ru Here’s an example of what a final looks like: config.ru https://gist.github.com/parterburn/67e27d302b79d70272c1 Forward /blog to /blog/ Since the blog is technically hosted at /blog/, we need to forward the /blog requests there (notice the non-trailing slash). Add to : config/routes.rb get '/blog' => redirect(" ") https://yourdomain.com/blog/ Forward an existing subdomain (optional) If you had already been using a domain like before, you’ll also want to setup a forward for the subdomain as well: blog.yourdomain.com Add to : config/routes.rb # Only necessary if you had blog.yourdomain.com setup before:get '(*path)', to: 'application#blog', constraints: { subdomain: 'blog' } Add to : app/controllers/application_controller.rb def blogredirect_to "https://yourdomain.com/blog#{request.fullpath.gsub('/blog','')}", :status => :moved_permanentlyend If needed, here’s a guide for how to . Implement Routing for Subdomains Turn on SSL (optional) If your existing site has SSL turned on (which it should), you’ll want to do a few more things in order to turn on SSL throughout the blog. Google is now , so you should definitely take this extra step even if you are not today. ranking sites higher for SSL The free should suffice if your site doesn’t need the absolute maximum compatibility (or you don’t already have an SSL certificate). Otherwise, you’ll need to enable the $10/mo SSL add-on. They’ll send you a .CSR file, but you’ll also need the .KEY file in order to update your certificate on Heroku — just shoot an email to help@getflywheel.com and they’ll send it over. The site I setup had their certificate through GoDaddy, so I followed to re-key it. Simple SSL in Flywheel this guide Re-key certificate on GoDaddy using the .CSR file that Flywheel sent you Download the new certificate & combine them (shown ) here Run in order to update your certificate on Heroku (server.key is the file that Flywheel sent you) heroku certs:update combined.crt server.key That updates your SSL for your site on Heroku. Flywheel will take care of updating it on their end. You’ll want to install the two plugins on your Wordpress to force it into SSL mode: Force SSL URL Scheme Wordpress HTTPS You’ll also want to take a look at in order to turn back on the Visual Editor inside Wordpress. this article Thanks for reading! If you need any help in getting this setup, don’t hesitate to tweet me: . @parterburn