I have a website in AWS hosted in an EC2 instance. I successfully configured SSL certificate via Classic Load Balancer and I can ONLY access https version of my website.
I am getting request timed out on the HTTP version of my website.
What I want to do is to permanently redirect the traffic from HTTP to my HTTPS site.
I don't want to do it via .htaccess
since AWS does not recommend it.
I've been trying different configs in my /etc/apache2/site-available/000-default.conf file but still doesn't work.
Here are some configs I tried
this is the first one
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =replaced-this-with-my-domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
and this is another one
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect / https://replaced-this-with-my-domain.com/
</VirtualHost>
Do I need to edit other configurations other than the /etc/apache2/site-available/000-default.conf file?