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.

Redirect WWW to non WWW, for primary domain, and parked domain

Discussion in 'General Discussion' started by basketmen, Oct 25, 2011.

  1. basketmen

    basketmen Well-Known Member

    Joined:
    Sep 9, 2010
    Messages:
    118
    Likes Received:
    0
    Trophy Points:
    16
    Hi guys,

    I already know basic Redirect www to non-www, using htaccess:






    but how if we have parked domain too?

    I already tried this but its not works, its says "The page isn't redirecting properly"





    please share your knowledge, what is the best way for this?
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The better option would be not to specify the domain name in the rewrite condition so that it redirects all www to non-www for that account:

    Code:
    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    If you also want all https traffic to go to non-www, then this should work:

    Code:
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
     
Loading...

Share This Page