Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    27

    Default Auto-redirect www subdomain

    Hello,

    Using my current configuration, when I create a new account in WHM it allows users to access the site using:

    http://domain.com

    AND

    http://www.domain.com

    How can I make it so that by default, when *any* new account is created, all accesses from http://domain.com be redirected automatically to http://www.domain.com.

    What I'm looking for here is not a one-time solution (I know this type of manipulation can be done manually by editing the .htaccess file on the newly created account), but rather a global solution that I can apply to the whole server and that would be applied to any newly created accounts.

    I know search engines can penalize sites for showing duplicate content on different subdomains so would like to be able to avoid this, if at all possible.

    Thanks!
    nCube Solutions powers businesses on the Web

  2. #2
    Member bvierra's Avatar
    Join Date
    Jul 2006
    Location
    Southern California
    Posts
    55

    Default

    just make a .htaccess file and drop it into the the skel dir

  3. #3
    Member
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    27

    Question

    I don't know what syntax I would use to make .htaccess rules that would be valid on different domains.

    I would normally set it up like this (for redirecting www to non-www):

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.domainexample.com$ [NC]
    RewriteRule ^(.*)$ http://domainexample.com/$1 [R=301,L]
    How would I make this work as a general solution for *any* domain?

    Thanks!
    nCube Solutions powers businesses on the Web

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    3

    Default

    Ok, so looking at your example for www to non-www, if you wanted that to work on ANY domain, then you need to build up a regular expression to capture that appropriately (and of course, reverse it, since your original question was to go from non-www to www). Here is an article with some pretty good starter points:
    non-www to www for any domain (primary and parked domains)

    Hope that helps!

    Quote Originally Posted by Xavior82 View Post
    I don't know what syntax I would use to make .htaccess rules that would be valid on different domains.

    I would normally set it up like this (for redirecting www to non-www):

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.domainexample.com$ [NC]
    RewriteRule ^(.*)$ http://domainexample.com/$1 [R=301,L]
    How would I make this work as a general solution for *any* domain?

    Thanks!

Similar Threads & Tags
Similar threads

  1. Canonical redirect of www to non www for the same domain
    By Vince778 in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 08-24-2011, 02:22 AM
  2. 302 Redirect of www to non www for the same domain
    By Vince778 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-22-2011, 07:01 PM
  3. redirecting www version of a subdomain to a non-www versioni
    By jpratt in forum Feature Requests for cPanel/WHM
    Replies: 0
    Last Post: 05-06-2011, 09:35 AM
  4. Auto-redirect www subdomain
    By Xavior82 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 10-13-2009, 09:34 AM
  5. How do you redirect non-www to www prefixed domains??
    By DReade83 in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-09-2008, 09:51 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube