views:

29

answers:

1

I have the following bunch of domains:

  • myDomain.de
  • myDomain.com
  • myDomain.co.za
  • myDomain.org
  • myDomain.com
  • myDomain.com.na

What is the shortest way to write in the htaccess, to make ALL domains...

  1. Redirect to https://www.myDomain.com. I.e. Regardless of the domain that is entered, it will add www AND redirect to https, and
  2. Still work on my localmachine (so that if someone types in http://localhost/site/src that it won't redirect to the www sites?
+1  A: 

Let's see if this works:

RewriteEngine On

# Check if the host name contains a . (localhost won't)
# Check if the host name starts with www
# Check if the host name ends with .com
# Check if the connection is secure
RewriteCond %{HTTP_HOST}  \.
RewriteCond %{HTTP_HOST} !=svn.myDomain.com
RewriteCond %{HTTP_HOST} !^www   [OR]
RwriteCond  %{HTTP_HOST} !\.com$ [OR]
RewriteCond %{HTTPS}     !=on
RewriteRule ^.*$ https://www.myDomain.com/$0 [R=301,L]
Tim Stone
It works, but now everytime i try to checkout anything using svn.mydomain.com, it says it cant because there is a perment redirect to https. how do I skip these rules if the person is accessing svn.mydomain.com ?
RD
I added in another condition, see if that fixes the problem.
Tim Stone