Tuesday, September 12, 2017

Apache HTTP Server: Redirect All HTTP Requests to HTTPS

Command:

# diff httpd.conf httpd.conf.bkup20170901


Result:

1005c1004
< <VirtualHost *:80>
---
> #<VirtualHost *:80>
1008,1009c1007
<      ServerName www.SERVERNAME.com
< Redirect / https://www.SERVERNAME.com/
---
> #    ServerName dummy-host.example.com
1012,1013c1010
< </VirtualHost>
<
---
> #</VirtualHost>


Reference:

https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https/21798882#21798882