How to use WordPress Landing Pages plugin using NGINX & Subdirectory

Post written by Hunter Miller
On Thursday, September 7th, 2017

Hi guys,

I just wanted to post this for anyone running into issues with the landing page plugin not switching in this strange WordPress environment.

I have a WordPress environment where it actually runs straight on NGINX not as a reverse proxy to Apache. Additionally, WordPress is in it’s own subdirectory. There are two issues with this setup:

  • A/B Switching won’t work because the module tries to load wp-load.php from the top directory of the site, not any sub-directories
  • The redirect system the plugin uses that is placed in .htaccess will have no effect because Apache doesn’t exist.
  • You may be using fastcgi caching which could also affect your landing page variations from being served.

Here’s what I had to do to fix it, which is not a permanent fix, but there’s probably a way to make it more permanent.

First, in the plugin file landing-pages/modules/module.redirect-ab-test.php, place the subdirectory that your WordPress runs in preceding /wp-load.php.

Second, you need to add a redirect in your NGINX config:

if ($args !~ "lp-variation-id") {
   rewrite (?i)^/go/([^/]*)/?$ /wp-content/plugins/landing-pages/modules/module.redirect-ab-testing.php?permalink_name=$1 last;
}

Third if you have caching enabled you will need to have an if statement to match your landing pages and set your skip cache variable.

I hope this helps someone. It took quite a bit of searching and reading error logs to figure out what was going on, and there’s no documentation here for a similar setup.

Thanks!

About the Author:
Inbound Now customer and experienced frontend Developer who loves working on quirky and creative web projects that push the limits of technology. Skilled in Web Dev, Web Perf, JS, CSS, Node.js, and UX. I also do web consulting on the side, so hit me up!

Continue Reading

Signup and get started with Inbound Now

Sign Up for Free

Download

[gravityform id="3" name="Popup Form" title="false" description="false" ajax="true"]