Search code examples
amazon-web-servicesdrupal-7amazon-elastic-beanstalkaws-application-load-balancer

Drupal 7 non-www to www


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


Solution

  • 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