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
    I have this htaccess file and need to have always www. befor the domain.
    How can i fix this? It's a multilanguage 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]
    [ed. note: fourroses666 last edited this post 13 years, 11 months ago.]
      Evolution user, I like the back-end speed and simplicity smiley
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      This doesn't work?

      # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
      #RewriteCond %{HTTP_HOST} .
      #RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
      #RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
      #
      # or for the opposite domain.com -> www.domain.com use the following
      # DO NOT USE BOTH
      #
      #RewriteCond %{HTTP_HOST} .
      #RewriteCond %{HTTP_HOST} !^www\.example-domain-please-change\.com [NC]
      #RewriteRule (.*) http://www.example-domain-please-change.com/$1 [R=301,L]
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 9995
        • 1,613 Posts
        huh, yours didn't work, i found something that worked but it's the same code lol, i guess i made a small mistake or smt!

        thanks for your help anyway smiley

        # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
        RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} !^www\.xxxx\.com [NC]
        RewriteRule (.*) http://www.xxxx.com/$1 [R=301,L]
        [ed. note: fourroses666 last edited this post 13 years, 11 months ago.]
          Evolution user, I like the back-end speed and simplicity smiley
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          I pulled it directly from the ht.access file. I don't much like www so I don't use it, but by all rights it should work, it's the same in every MODX installation.
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster