http://domain.com to http://www.domain.com

Discussion in 'Apache' started by Blonde Jon, Apr 11, 2008.

  1. #1
    Blonde Jon, Apr 11, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Hello,

    If your users access https://mydomain.com and you want them to redirect without the (SSL) warning, this is not possible. The only possible combination is an unsecure to secure redirect such that:

    http://mydomain.com => https://www.mydomain.com

    A lot of sites suffer from this problem (including some like PayPal), and the only solution is to obtain a SSL certificate with two CN (common name) entries, one with the www, and one without. GoDaddy offer multi-domain SSL certificates, but as you've already got a standard one, I doubt you want this. This solves the problem of two SSL domains on a single IP (at a cost).

    Hope this helps you,

    Jay
     
    jayshah, Apr 12, 2008 IP
  3. ezcat

    ezcat Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    htaccess...
    Options +Includes
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.yours.com$ [NC]
    RewriteRule ^(.*)$ http://www.yours.com/$1 [L,R=301]
    don't know if this will show on this post but hopefully it will... good luck.
    I use this on all my sites and I do have one which is with no www... works fine
     
    ezcat, Apr 12, 2008 IP
    Blonde Jon likes this.
  4. ezcat

    ezcat Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I know it looks wierd but believe me it works... add it and then try going to your site without the www
     
    ezcat, Apr 12, 2008 IP
  5. Blonde Jon

    Blonde Jon Active Member Affiliate Manager

    Messages:
    745
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Thanks ezcat!

    After I made this post, I was searching around and found the same modrewrite that you have there. But I have a twist I currently have this in my .htaccess

    DirectoryIndex index.html index.php
    
    <IfModule mod_rewrite.c>
    RewriteEngine on
    # Some hostings require RewriteBase to be uncommented
    # Example:
    # Your store url is http://www.yourcompany.com/store/cscart
    # So "RewriteBase" should be:
    # RewriteBase /store/
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php?sef_rewrite=1 [L,QSA]
    
    </IfModule>
    Code (markup):
    I need to keep the above plus force www. Do you know how to do that?

    Thanks,

    Jon
     
    Blonde Jon, Apr 12, 2008 IP