Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

As of now I use this rule (in .htaccess of to redirect HTTPS/HTTP to

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,L]

And from searching, I found that the following rule redirects HTTPS to HTTP:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

How do I combine these, so that - - redirects to and then, redirects to

I cannot explain why I am not asking for something like this - - HTTPS/HTTP:// redirects to In short, I have searched and asked, and the rules suggested aren't working, probably coz I am using a self-signed cert, and the same cert for the two domains ( is an addon domain, and is the main domain). Please advise, if that makes sense.

share|improve this question

Interesting requirement, I'm not sure I understand why you'd do this - it's just making it take two 301 responses to get to instead of one.. But, I suppose this'll do it:

RewriteEngine on

# First rule - if this is an SSL connection, then redirect
# to then stop processing other rules
RewriteCond %{HTTPS} on
RewriteRule (.*)$1 [R=301,L]

# Second rule - all other requests, redirect to
RewriteRule (.*)$1 [R=301,L]
share|improve this answer
Can you post your <VirtualHost> configs? Looks like requests to are being answered by the vhost, and thus not redirecting. Requests to are redirecting, but to and not - fix that in the config. – Shane Madden Oct 25 '11 at 1:20
Here go the rules in my httpd.conf file : (is that what you asked for?) – user88753 Oct 25 '11 at 1:51
Those are some ominous capital letters, that's for sure. I'm only seeing the one actual vhost on :443 - is there not one in place for – Shane Madden Oct 25 '11 at 1:58
I actually don't know about these. I will contact my web host and see what they can do about it. Kindly check back this thread tomorrow. I will post the update here (any changes). Thanks. – user88753 Oct 25 '11 at 2:04
My webhost took all the time in the world to tell me that it's not HTTPS redirect an addon domain to another domain under the same Cpanel account, as they both share a common SSL certificate. Looks like the only way is to create a separate account for the addon domain? – user88753 Oct 25 '11 at 10:58
up vote 0 down vote accepted

Thanks for all the help @Shane Madden. Got it all worked out. This was the .htaccess (of rule that I was and am using:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

The reason it didn't work before was because the two domains were using the same SSL certificate (as one is an addon domain under the Cpanel account of another domain). "HTTPS redirection does not work for addon domains."

So, what I did was create a new cpanel account for That is, get a separate SSL cert for As simple as that.

share|improve this answer
This only redirects HTTP/HTTPS:// to The answer by @Shane Madden redirects every single thing on the server to Use whatever suits you best. :) – user88753 Oct 25 '11 at 14:57

protected by Community Dec 17 '15 at 18:49

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?