I am trying to configure apache with SSL. I am facing 2 issues:

1) If typed www.example.com it doesn't redirect to https://example.com (Though, i have written the rewrite rule).

2)And while running https://example.com it shows unauthorized label with https.

Here is a reference of how my apache configuration file look a like.

<VirtualHost *:443>

  ServerName  example.com
  ServerAlias www.example.com

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  RewriteRule ^(.*)$ https://example.com$1 [L,R=301]

  SSLEngine on
  SSLCertificateFile PATH_TO_CERTIFICATE_FILE
  SSLCertificateKeyFile PATH_TO_PERMISSION_KEY_FILE
  SSLCertificateChainFile PATH_TO_GD_BUNDLE_CERTIFICATE_FILE

</VirtualHost>

I have enabled my mod_ssl.

I would highly appreciate if anyone can throw some light on this.

link|improve this question
feedback

1 Answer

up vote 3 down vote accepted

I assume you're looking to redirect http://www.example.com to https://example.com. In order to do that you'll need to have a VirtualHost instance listening on port 80 and put the rewrite rules there.

link|improve this answer
That worked. Thanks. The Second problem still persists. I checked domain SSL certificate which is fine. The problem i think here is that example.com loads others resources like JS and CSS(say: static.example.com) which is not running over https. So, it gives a warning. What do you think? is this could be the issue? – aatifh Jun 20 '11 at 18:30
@aatifh - Yes. If current page uses HTTPS then static.example.com site has to be on HTTPS as well. For that you would need to set it up on another IP:port combination .. or obtain wildcard SSL certificate that will cover both of these domains. Check this link: Is it really a security problem to have non secure assets on an ssl page? – LazyOne Jun 20 '11 at 23:01
LazyOne: Thanks a lot.:) – aatifh Jun 21 '11 at 6:33
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.