0

I have a website. I bought all (mydomain.com|net|org|co) domains for my website. Now, I want to redirect all my requests to mydomain.com.Presently, in my httpd.conf, I have ReWrite rules for forwarding http requests to https.

For forwarding all http requests to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I combined my existing settings with this answer and I tried following code:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} !^example.org$
RewriteRule ^ http://example.org%{REQUEST_URI} [L,R=301]

It is working fine for http requests but not for https(https://mydomain.net/info). I got SSL certificate for mydomain.com. It is displaying me This Connection is Untrusted page.

What would be best way to handle this scenario. Can anyone guide me on this

Thanks in advance,
deadMan.

Community
  • 1
  • 1
deadMan
  • 35
  • 1
  • 7

1 Answers1

0

Try this:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.com%{REQUEST_URI}
RewriteCond %{HTTP_HOST} !^example.com$
RewriteRule ^ http://example.com%{REQUEST_URI} [L,R=301] 
ADev
  • 686
  • 4
  • 13
  • I tried above code. I have SSL certificate mydomain.com. When I used your rule, https://mydomain.net throwing me Untrusted connection instead of redirect. – deadMan Aug 18 '12 at 05:20