0

I have adjusted the .htaccess file in drupal 7 to forward non www to www domains. When I deploy this to AWS elastic beanstalk (with app load balancer) I get lots of 3xx errors for about 50% of the traffic (I have 2 instances).

Any idea why? Any idea how I can solve this or achieve the same redirect in another way?

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Thanks

Alex
  • 96
  • 1
  • 2
  • 7
  • When you deployed, can you verify that both instances are running the same code? The 50/50 split would have me think that one instance hasn't updated correctly. – Frank Robert Anderson Feb 06 '19 at 18:23
  • I had reduced it to one instance, same problem. I found out that the 3xx errors were being caused by the redirection from non www to www in the drupal htaccess file. How do I stop this as it shows as a degraded environment. The redirection works as prescribed though... all requests go to the correct place. – Alex Feb 06 '19 at 19:51

1 Answers1

0

You can use the application-load-balancer for doing the redirection.

Basically: Console > EC2 > Load-Balancers > Listeners

Here you can select

  • HTTP : 80 > View/edit rules
  • HTTPS : 443 > View/edit rules

You can find more information here: AWS Tutorial on rewriting

ohlr
  • 1,839
  • 1
  • 13
  • 29