Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently added a wildcard SSL certificate to my sites. How can I get it so when a user goes the sites, it forces them to https?

The SSL covers sites in the form of *, I need it to make all those sites go to the https version. However, there is also another site on the same server that is * which doesn't have SSL and should not redirect to https.

I've looked at using .htaccess files with redirect but not only could I not get it to work, I would like to make it a server wide change and not need a .htaccess file for every site.

I also found another problem where I can only access the https sites inside my office but nowhere else.

share|improve this question
Your "another problem" should be posted as a separate question so an answer to this one which answers the redirect issue can be marked accepted. – pjmorse Sep 29 '12 at 0:49

The easiest way of doing this is with .htaccess as you mention. It is possible to put the rewrite rules in the Apache configuration if you prefer. Depending on the layout of your file system and Apache configuration it may also be possible to create a pattern matched <Directory> entry in the configuration that matches all your SSL enabled sites.

A quick search of the net suggests the following should redirect non-SSL requests to https://

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

If you are accessing from external through a NAT router and http:// works then I would suggest the problem is most likely that port 443 is not forwarded to your web server.

share|improve this answer
How do I forward port 443? I have a little bit of experience with Red Hat and Apache, but not enough. – Sean Sep 28 '12 at 14:41
It sounds like your server is configured correctly. It's the router that connects your network to the Internet that needs configuring to forward port 443. (I'm assuming your server is on a private address on your LAN and you have a NAT router like most offices) – USD Matt Sep 28 '12 at 15:24
Are there any other rewrite conditions so I can keep one of the sites from redirecting? – Sean Sep 28 '12 at 19:16
You could probably add a second negative condition as above but using the %{SERVER_NAME} variable to exclude the host name of your non ssl website. I'm not much of a mod_rewrite expert, have a look on the net for example of using multiple conditions. – USD Matt Sep 28 '12 at 19:31

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.