0

I have my Amazon linux server and I had been installed httpd24 and mod24_ssl. I had been setup ssl certificate in /etc/httpd/conf.d/ssl.conf file with https redirect instructions:

<VirtualHost *:80>
ServerName example.com:80
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost _default_:443>
ServerName example.com:443
SSLEngine on
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLProxyProtocol all -SSLv3
SSLHonorCipherOrder on
SSLCertificateFile /etc/example.com/cert.pem
SSLCertificateKeyFile /etc/example.com/privkey.pem
SSLCertificateChainFile /etc/example.com/chain.pem
</VirtualHost>

But the httpd starts normally without any issue. But the redirection is not working. I have other file /etc/httpd/conf/httpd.confhere. What I might have missed.? I come across many articles but those didn't solve my problem.

Nagarjuna D N
  • 541
  • 6
  • 26

1 Answers1

0

You are missing RewriteEngine onPlease add that to the config file and restart Apache. Check edited below.

<VirtualHost *:80>
ServerName example.com:80
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost _default_:443>
ServerName example.com:443
SSLEngine on
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLProxyProtocol all -SSLv3
SSLHonorCipherOrder on
SSLCertificateFile /etc/example.com/cert.pem
SSLCertificateKeyFile /etc/example.com/privkey.pem
SSLCertificateChainFile /etc/example.com/chain.pem
</VirtualHost>
Piyush Patil
  • 14,512
  • 6
  • 35
  • 54