.htaccess Code To Insert Missing WWW

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tipsy
    Confirmed User
    • Jul 2001
    • 6989

    #1

    .htaccess Code To Insert Missing WWW

    Anyone have some working htaccess code to add the www to a url? The one I have gets pissy with a script I'm trying to setup and I can't find the alternative version I had which should work.

    Thanks.
    Ignorance is never bliss.
  • fireorange
    Confirmed User
    • Jan 2005
    • 1648

    #2
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.domain\.com
    RewriteRule (.*) http://www.domain.com/$1 [R=permanent,L]

    Comment

    • Tipsy
      Confirmed User
      • Jul 2001
      • 6989

      #3
      Originally posted by fireorange
      Code:
      Options +FollowSymLinks
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\.domain\.com
      RewriteRule (.*) http://www.domain.com/$1 [R=permanent,L]

      That's what I have and it gets a little pissy with a script I have. I'm sure I've seen another way of doing it and even saved it but can't find it now

      Thanks for the reply though.
      Ignorance is never bliss.

      Comment

      • swami
        Confirmed User
        • Aug 2003
        • 1989

        #4
        Are we talking about redirecting the root to the www.alias?
        This is what I use
        Options +FollowSymLinks -Indexes
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^domain\.com
        RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]

        Comment

        Working...