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
    When u type domain.com i want to force it to go to www.domain.com

    I have a website with this htaccess:

    # 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]


    Because its a multilanguage site with Yams its a little different as the standard one.

    What i like to have is that it forces the www. befor it.

    I have tried this but didn’t work:

    RewriteCond %{HTTP_HOST} !^www.xxx.nl$
    RewriteRule ^(.*)$ http://www.xxx.nl/$1 [R=301]

      Evolution user, I like the back-end speed and simplicity smiley
      • 36404
      • 307 Posts
      Hi,

      you may try
      RewriteCond %{HTTP_HOST} !^www.xxx.nl$
      RewriteRule ^(.*)$ http://www.xxx.nl/$1 [QSA,L,R=301]

      just between the Fix apache dummy... and Exclude /assets... lines

      have swing
        réfléchir avant d'agir
        • 9995
        • 1,613 Posts
        nice, works like a charm laugh
          Evolution user, I like the back-end speed and simplicity smiley