htaccess redirec from domain.com to www.domain.com (ssl)

Discussion in 'Apache' started by enezeusx, Mar 14, 2008.

  1. #1
    Hi
    .htacsess drive me nuts, help!

    Im trying to redirect HTTP://DOMAIN.COM to HTTP://WWW.DOMAIN.COM because the ssl certificate is to the site WWW.DOMAIN.COM and not DOMAIN.COM.

    I do the following, htaccess file:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI}

    Then when I type domain.com (without www)on the navigation bar of the browser, it redirect me to https://www.domain.com (with www. and ssl) it works, good.

    BUT when I type www.domain.com (with www) on the navigation bar of the browser, it redirect me to https://www.www.domain.com (twice www) :confused:

    ideas, solutions, tips or a cold glass water are welcome

    Thanks i advance
     
    enezeusx, Mar 14, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Here is the solution I have:

    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.YOURDOMAIN.com%{REQUEST_URI}
    
    Code (markup):
     
    jayshah, Mar 15, 2008 IP
    enezeusx likes this.
  3. enezeusx

    enezeusx Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    It works! it works! Im going to sleep well tonight. Thanks master jayshah!
     
    enezeusx, Mar 15, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    You're welcome :)

    Any chance of a Reputation :D

    Thanks!
     
    jayshah, Mar 16, 2008 IP