How do I redirect www.domain.com to domain.com?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Snake Doctor
    I'm Lenny2 Bitch
    • Mar 2001
    • 13449

    #1

    How do I redirect www.domain.com to domain.com?

    I've heard you can do this in htaccess but I don't know the code.
    Anyone have it handy?

    Thanks
    sig too big
  • cranki
    Confirmed User
    • Feb 2005
    • 5162

    #2
    this is from domain to www.domain ... maybe just switch it vice versa...

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

    Comment

    • madawgz
      8.8.8.8
      • Mar 2006
      • 30509

      #3
      Originally posted by cranki
      this is from domain to www.domain ... maybe just switch it vice versa...

      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^domain\.com [NC]
      RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
      whoa, some complicated scripting you got there
      TAEMDLRMSKRJIXMRLSMRJ.

      Comment

      • Quickdraw
        Confirmed User
        • Mar 2004
        • 1717

        #4
        There is more than one way, but I believe this should work

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www\.domain\.com
        rewriterule (.*) http://domain.com/$1 [R=permanent,L]

        Comment

        Working...