Saturday, June 1, 2019

apache 2.2 - How to redirect http to https for IP and domain on Apache2

I have an Apache2 web server running on Ubuntu 12.04. The domain of the website that I am hosting works fine, and if you go to the http version instead of the https version, it automatically redirects to the https version of the domain.



However, if I go to the http version of the ip address of the domain, it does not automatically redirect to the https version of the ip address.




There is nothing in the .htaccess or httpd.conf file.



I have tried adding a redirect for the ip specifically in the .htaccess file, but it does not work properly and the when I visit the domain, it says there are too many redirects.



I have a default-ssl file and website file in the sites-enabled folder. The default-ssl has virtual host config for port 443 and the ServerName



The website file has virtual host config for port 80, but no ServerName



Both files have the same DocumentRoot




How do enable the https redirect for the ip address as well, not only the domain?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...