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.

www or no www, that is the question!

Discussion in 'General Discussion' started by shannon, Mar 26, 2003.

  1. shannon

    shannon Well-Known Member

    Joined:
    Mar 25, 2002
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    Alright, have a simple problem, and yet, I've been pondering it all day and am still not seeing the solution, though I'm sure it's staring me right in the face.

    Lets say you have a cpanel account where the domain is abc.com, as normal, when the account is created, you can access it at either abc.com or www.abc.com.

    Now lets say you want any requests that use http://www.abc.com to revert over to http://abc.com, and to show as such in the browser bar.

    Now, I know it can be done, I've seen it done, I'm just not thinking right now of HOW to do this with a cPanel account. ;)

    First thought was "redirect!".. but of course, redirects take a pathname as the first part, not a URL. So although I could do a:

    Redirect / http://abc.com

    that results in an endless loop, as both the www and non www 'sites' pull from the same directory (and thus same .htaccess file!)

    And since putting http://www.abc.com/ in place of the first / in that redirect makes it no longer work (paths, not URLS!).. I'm going slowly insane trying to put my finger on the solution here. Thought about playing with the httpd.conf file (Server Alias, or one of those should let me do it?!).. but I'm worried that at some point WHM is going to re-build httpd.conf and wipe out my changes.. and obviously, I can't chattr +i httpd.conf without major problems down the road. ;)

    Any ideas?!
     
  2. shannon

    shannon Well-Known Member

    Joined:
    Mar 25, 2002
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    Ah, but both www.abc.com and abc.com use the same content by default on a cPanel box.. so a meta-refresh or java-refresh would affect both sites.. (And cause the same infinate loop one experiences with the "Redirect / abc.com" idea).

    Although so far, a php code snippet that looks at the url requested, and if it's www.abc.com redirects it over to just abc.com is right now the only way I can think to do this, it's also kind of a kludgey way of doing it. ;)
     
Loading...

Share This Page