• Resolved vaporsyndicate

    (@vaporsyndicate)


    Set up WordPress 4.5.2 on Elastic Beanstalk following this guide: https://d0.awsstatic.com/whitepapers/deploying-wordpress-with-aws-elastic-beanstalk.pdf

    All points of the walkthrough were followed exactly- with the following exceptions…

    The MySQL database was set up directly through RDS using ElastiCache rather than through the Eliastic Beanstalk interface. (No issues on database connectivity)

    I am using a development domain name rather than the CloudFront domain. (No issues resolving to any page on the site prior to activating multisite)

    NOTE: Domain is registered with GoDaddy (updated with custom NS info). Hosted Zone is set up in Amazon Route53. A Record for domain (no www.) is pointed to the CloudFront endpoint. One CNAME record points www. to just domain (no www.).

    WordPress Address and Site Address (in WP General Settings) are both pointed to https://mydevsitename.com

    The only active Plugins on the site are W3TotalCache (for CDN through CloudFront – Origin Push) and WP SEO by Yoast (Current versions of both). Theme is 2016 – no modifications.

    Enable WP multisite was in my wp-config.php file. Enabled subfolder multisite network through Tools / Network. Grabbed the code to change .htaccess and wp-config.php

    Here is the .htaccess code generated…

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    Made change to .htaccess using the .htaccess file editor in the WP SEO by Yoast plugin to avoid having to deploy a new EBS application. Verified changes by downloading the .htaccess from the active EC2 instance. (Site still accessible from front end after changes made.)

    Here are the wp-config changes generated…

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', 'mydevsitename.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    I downloaded the web folder from the staging environment (folder /var/app/current/) locally. I added this code to wp-config.php. (Also checked that the .htaccess file maintained the changes I had made.) Zipped it up and deployed it as a new application in Elastic Beanstalk. This creates a redirect loop on the front end of the site.

    I am still able to navigate through WP Admin areas without any issues – 100% functionality. (Uploading media, installing plugins, adding new sites to the network, etc.) However, I can only get to the admin by going to https://mydevsitename.com/wp-login.php

    There is ZERO functionality on the front end because of the redirect loop.

    The redirect loop only starts AFTER I make the updates to the wp-config file.

    I spent an hour on the phone with an Amazon engineer who was able to confirm all of my AWS settings were correct and that the problem was within the code of the site. He suggested .htaccess as the place to look, but the site doesn’t break until wp-config is updated.

    This makes no sense to me whatsoever. Any help would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter vaporsyndicate

    (@vaporsyndicate)

    Finally figured out a resolution to this issue. Thought I would share in case anyone else runs into the same problem…

    The issue was caused because of when the WordPress installation was converted to multisite.

    Even though this was a fresh install, the WP install should be switched over to multisite BEFORE setting up W3 Total Cache. I’m assuming that the cache files and configurations for a single site can create redirect loops when WP is switched to multisite.

    Thread Starter vaporsyndicate

    (@vaporsyndicate)

    Resolved

    Hi vapoursyndicate!

    I am having exactly this issue and it’s driving me nuts. I am new to AWS and everything looks the same as your set-up (and I have rebuilt a couple of times to check). One question though, when you say your Cloudfront endpoint, in the alias drop-down list in Route53, is that the Cloudfront Distribution, or the Cloudfront origin (which would be the ELB origin path). I have also tried not installing W3 until after Multisite and it still stuffs up.

    Any help would be much appreciated.

    R. Sam

    Thread Starter vaporsyndicate

    (@vaporsyndicate)

    In Route 53, try setting the value of your A record to the ELB Classic Load Balancer for your ELB app. To get the full function of the EC2 scaling you want all your incoming traffic to go through the load balancer.

    Also, in Route 53, try using the Test Record Set button at the top of the page in the Hosted Zone. That could give you some helpful clues in getting your redirect loop straightened. out.

    One other point to check is your Origins and Behaviors in CloudFront.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect Loop on new WP MultiSite install on AWS Elastic Beanstalk’ is closed to new replies.