Site icon GetPageSpeed

Magento WordPress Multisite Nginx Integration by Fishpig

Magento Wordpress Integration

Magento Wordpress Integration

If you own a Magento shop, you may want to increase its SEO by adding a WordPress blog to it. But what is the best way to add it? One of the popular choices is using a Magento plugin to display WordPress blog inside Magento frontend interface. This Magento WordPress integration technique will nicely wrap the blog posts and display blog posts within your store template.
Fishpig WordPress integration plugins are best way to implement it. The Magento plugin is easy to setup and well documented.

But what if you have multi-store Magento installation, with each store residing on a different domain? And you want each store front to have its own WordPress blog. Well, they have solution for this case as well – you would create a WordPress multisite installation and then make use of additional Magento plugin “Multisite Integration“.

The latter plugin has little less documentation.

Magento WordPress integration with multiple store views and blogs

Let’s review the steps needed to integrate multi-store Magento installation with WordPress on Nginx web server.

We assume you’ve already created all your Magento stores. Suppose that we have three stores configured within single Magento installation:

We want each Magento store view to have a WordPress blog, so our goal is having these pages display WordPress blog posts:

All the /blog/ URLs will display different blog posts, of course.

First thing you need to do is to make sure that Nginx will properly rewrite requests to WordPress.
Open configuration of Magento site server block in Nginx and put the following:

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
  rewrite /wp/wp-admin$ $scheme://$host$uri/ permanent;
  rewrite ^/wp/[_0-9a-zA-Z-]+(/wp-.*) /wp/$1 last;
  rewrite ^/wp/[_0-9a-zA-Z-]+(/.*\.php)$ /wp/$1 last;
}

location /wp {
   index index.php;
   try_files $uri $uri/ /wp/index.php?$args;
}

Please refer to plugins documentation and WordPress on performing the following steps to make things work as expected. The important step is #7 for our purpose.

  1. Locate your Magento files and create /wp/ directory there. It should be on the same level with Magento’s /app/ directory.
  2. Install WordPress into /wp/ directory
  3. Install “WordPress Integration” Magento plugin. Then integrate first Magento store with the WordPress site we have in subdirectory.
  4. Convert the WordPress site into multisite
  5. Install “Multisite Integration” Magento plugin
  6. Most important step. In WordPress, create Network sites and specify site URL and home URL using these rules:
    • site URL should always point to domain of the first Magento store view. It must be in subdirectory of /wp/, i.e. /wp/store_code/ (except for the first WP site).
    • home URL should be the /blog/ URL with the proper store view domain where you expect Magento to render WordPress blog posts.

WordPress network sites for our example

WordPress site #1:

Site URL: http://aaa.getpagespeed.com/wp/
Home URL: http://aaa.getpagespeed.com/en/blog/

WordPress site #2:

Site URL: http://aaa.getpagespeed.com/wp/bbb_en/
Home URL: http://bbb.getpagespeed.com/en/blog/

WordPress site #3:

Site URL: http://aaa.getpagespeed.com/wp/ccc_en/
Home URL: http://bbb.getpagespeed.com/en/blog/

WordPress site #4:

Site URL: http://aaa.getpagespeed.com/wp/ccc_ru/
Home URL: http://bbb.getpagespeed.com/ru/blog/

Again, take note that the domain of site URLs of all WordPress blogs is the same to base Magento domain and does not vary. It’s the home URL that is domain dependent.

Magento WordPress integration with multiple sites is tricky, but using the approach described it’s pretty straightforward to implement.

Exit mobile version