views:

39

answers:

2

Guys,

I'm looking for a simple way to have this done. I would to have the .htaccess file rewrite to HTTPS if this is typed in the address bar:

  • www.example.com
  • example.com
  • http://www.example.com

I would like any of these potabilities redirect to https://www.example.com

Thanks guys... I haven't found anything for this situation.

Just wanted to say that the answer below did not work for me... is there anything else I can do?

A: 

The easiest way to do this is to check the port the request is coming in on.

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mydomain.org/$1 [R=301,L]
Laurence Gonsalves
Yeah this isn't working for me...
Matthew
@Matthew In what way does it not work?
Laurence Gonsalves
Well I want it to point any entered combination to resolve to https://www.mydomain.org. The above option allowed me to enter mydomain.org and that would resolve to http://mydomain.org.Thanks for the response Laurence
Matthew
+1  A: 

Try this:

RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
Gumbo