How to use WordPress Landing Pages plugin using NGINX & Subdirectory
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!