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 setup a website where we would like to redirect the URL for a couple of different cases. The cases are below:

  • If port 80 then force port 443
  • If URL = support.example.com then force URL = support.example-1.com

We would like to first require all traffic to be on HTTPS and then require that one of our domain's when requested (since it resolves to the same box and due to our SSL certificate) is redirected to another one of our domains. We are able to get the force SSL to work, but we cannot seem to find a mod_rewrite rule that will work when https://support.example.com is requested to force it to https://support.example-1.com.

Any help that you can provide would be greatly appreciated. Thanks in advance.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You've done the force SSL so ignoring that.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^support\.example\.com$
RewriteRule (.*) https://support.example-1.com/$1 [R=301,L]

share|improve this answer
Did I just delete your comment by accident? Apologies if so. I'm going to assume you did it but if not let me know :) –  James L Dec 18 '10 at 0:39
I am not able to get that set of rules that you listed to work. It does not seem to redirect. If I start out with support.example.com then I am not redirected to support.example-1.com. I have added the rules that you listed to my SSL virtual host. I am not sure where to go from here. –  John Dec 18 '10 at 0:47
It works for me inside a .htaccess - I have the following in the .htaccess for *.jdlawrie.co.uk and it redirects test.jdlawrie.co.uk: RewriteEngine On RewriteCond %{HTTP_HOST} ^test\.jdlawrie\.co\.uk$ RewriteRule (.*) http://test.com/$1 [R=302,L]. Did you ensure you got your <Location> tags in the vhost file? Paste the configuration and I'll try to help. –  James L Dec 18 '10 at 0:51

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.