I'm running an app in Elastic Beanstalk using Tomcat. I set up my own domain name that I've added as a CNAME alias of the xyz.elasticbeanstalk.com
address for my environment and it all works well. What I'd like to do is redirect traffic accessing the site at xyz.elasticbeanstalk.com
to my own domain name.
I thought I could do this using .ebextensions in my WAR file like this:
myapp.config:
container_commands:
01_setup_rewrite:
command: "cp .ebextensions/redirect_canonical.conf /etc/httpd/conf.d/redirect_canonical.conf"
02_apache_restart:
command: /etc/init.d/httpd restart
redirect_canonical.conf:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.mydomain.com/$1 [L,R,NE]
I've used similar mod_rewrite rules before in a .htaccess
file and they worked well but because this is a mod_proxy I'm not sure if this is right (or if I can even put the rewrite command in the conf.d folder).
How can I configure it do redirect as I would like?