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.

non-www to www redirect

Discussion in 'General Discussion' started by Underpaid, Jun 22, 2005.

  1. Underpaid

    Underpaid Registered

    Joined:
    Jun 22, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thanks in advance for your help on this.

    I need to do a permanent redirect from the http://domain to the http://www domain. I'd like to do this via cPanel, but I cant get it to work.

    CPanel shows http://domain.com/ (blank) >> http:// (blank)

    I have filled the destination blank with the standard www.domaincom but this doesnt seem to work - the page just doesnt come up.

    Any suggestions ?
     
  2. ehpmahesh

    ehpmahesh Well-Known Member

    Joined:
    Jul 3, 2004
    Messages:
    74
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    www is CNAME of your domain name. If you give your domain name with www or without www it will goto the same location. So there is no need of putting redirection for www.
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
  4. Underpaid

    Underpaid Registered

    Joined:
    Jun 22, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    This is usally not considered duplicate content - what you show the SEs and users is the same page. However, there is also a security issue involved. You might want to read this: http://www.threadwatch.org/node/2817#comment-16744


    Well, I dont do code. So while I think I can figure it out, it makes sense to use cpanel if it works. Are you suggesting that cpanel cannot do this ??
     
    #4 Underpaid, Jun 23, 2005
    Last edited: Jun 23, 2005
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    There's no option in cPanel to do it AFAIK, if you want it, you'll have to do it yourself.
     
  6. Underpaid

    Underpaid Registered

    Joined:
    Jun 22, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    ok, thanks.


    seems like a simple thing cpanel should be able to do.
     
    #6 Underpaid, Jun 23, 2005
    Last edited: Jun 23, 2005
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    No, the mod_rewrite can go into a .htaccess file at the top of the site, i.e. /home/user/public_html/.htaccess
     
  8. EWD

    EWD Well-Known Member
    PartnerNOC

    Joined:
    Aug 19, 2003
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    NY
    I have a customer that wants the same thing.

    I have tried the following in the htaccess file but it kills subdomains.... any ideas?

    PHP:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase 
    /
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    </IfModule>
    while using the code above if I go to the subdomain test.domain.com will redirect to www.domain.com/test

    Any help would be appreciated.

    Thanks ;)
     
  9. chican0

    chican0 Well-Known Member

    Joined:
    Mar 26, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Los Angeles
    Within the root of your subdomain, place the following in an .htaccess file..

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^sub\.domain\.com
    RewriteRule ^(.*)$ http://sub.domain.com/$1 [R=permanent,L]
     
  10. philliephan

    philliephan Registered

    Joined:
    Jun 15, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Thank you!

    I realize this thread is just about 2 years old ... but I wanted to say thank you for the excellent information here. It just goes to show you how well the forum "search" function works! :D

    I used the last two codes posted in this thread and they both work perfect. They are exactly what I was looking for.

    The code:
    PHP:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase 
    /
    RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    </IfModule>
    Works perfect to redirect traffic from http://domain.com to http://www.domain.com and it works for any parked domains as well. It will redirect http://domain.net to http://www.domain.com

    And subdomains work perfectly when I use the last code:
    PHP:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond 
    %{HTTP_HOST} !^sub\.domain\.com
    RewriteRule 
    ^(.*)$ http://sub.domain.com/$1 [R=permanent,L]

    Again.. thanks so much!!
     
Loading...

Share This Page