0

I have my Amazon linux server and I had 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
  • 315
  • 1
  • 2
  • 16

1 Answers1

1

The RewriteCond %{HTTPS} off line is superfluous, any traffic hitting that virtual host is going to be HTTP by definition. You probably also need a RewriteEngine on directive as well to enable mod_rewrite.

bodgit
  • 4,751
  • 16
  • 27
  • Yes. Silly mistake by me. Thanks much. I did changed and redirect is happening now but its giving too many redirects while loading the page. – Nagarjuna D N Aug 03 '16 at 05:01