Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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


I have enabled my mod_ssl.

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

share|improve this question

1 Answer 1

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.

share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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