The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

rewrite via htaccess

Discussion in 'General Discussion' started by Host4u2, Nov 1, 2003.

  1. Host4u2

    Host4u2 Well-Known Member

    Joined:
    Mar 24, 2002
    Messages:
    248
    Likes Received:
    0
    Trophy Points:
    16
    Can any of you gurus tell me the code to add to an account's htaccess to rewrite all "www.domain.com" to automatically go to "domain.com" (without the www)? Can this be done using the htaccess file?
     
    #1 Host4u2, Nov 1, 2003
    Last edited: Nov 2, 2003
  2. Host4u2

    Host4u2 Well-Known Member

    Joined:
    Mar 24, 2002
    Messages:
    248
    Likes Received:
    0
    Trophy Points:
    16
    #2 Host4u2, Nov 2, 2003
    Last edited: Nov 4, 2003
  3. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16

    I just found this online:

    PHP:
    RewriteEngine On

    # force www IN URL
    rewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
    rewriteRule ^(.*)$ http://www.example/$1 [R=301,L]
    # END force www IN URL

    And it works.

    Regards,
    Damion
     
Loading...

Share This Page