We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    How can I make sure it always adds www. even if I type http://domain.com ?

    My htaccess file: (multilanguage YAMS website)


    # Friendly URLs
    RewriteEngine On
    RewriteBase /
    
    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    
    # Exclude /assets and /manager directories from rewrite rules
    RewriteRule ^(manager|assets) - [L]
    
    # Redirect from mydomain.com/rootname to mydomain.com/rootname/
    RewriteRule ^en$ en/ [R=301,L]
    RewriteRule ^nl$ nl/ [R=301,L]
    
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^en/(.*)$ index.php?q=$1 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^nl/(.*)$ index.php?q=$1 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    This question has been answered by thingstodo. See the first response.

    [ed. note: fourroses666 last edited this post 13 years, 8 months ago.]
      Evolution user, I like the back-end speed and simplicity smiley
    • discuss.answer
      • 37099
      • 338 Posts
      Try

      RewriteCond %{HTTP_HOST} ^domain\.com [NC]
      RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
        • 9995
        • 1,613 Posts
        Quote from: thingstodo at Jan 04, 2013, 06:49 AM
        Try

        RewriteCond %{HTTP_HOST} ^domain\.com [NC]
        RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

        I'm not really able to test it because the website is in the middle of a moving from servers. If it doesn't work I will post again smiley

        Thanks!
          Evolution user, I like the back-end speed and simplicity smiley