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 without www to www

Discussion in 'General Discussion' started by aaronpie, Jun 12, 2009.

  1. aaronpie

    aaronpie Member

    Joined:
    Jul 25, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I am trying to get my website to redirect when someone types mydomain.com to redirect to www.mydomain.com. Right now when someone types in mydomain.com the get the Great Success! Apache is working on your cPanel and WHM Server page.

    I have edit the .htaccess file in the root folder in my Joomla install with the following:

    RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

    Can anybody point me in the right direction to fix this. Thanks.

    - Aaron
     
  2. InstaCarma_Tech

    InstaCarma_Tech Well-Known Member

    Joined:
    Apr 22, 2009
    Messages:
    228
    Likes Received:
    1
    Trophy Points:
    18
    Try the following code in your .htaccess file.

    Code:
     RewriteEngine On
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^present site.com/$ [NC,OR]
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.present site.com/$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 
    Let us know if this doesn't solve the issue.
     
  3. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    That's not normal cPanel behavior!

    Something is wrong with your configuration because on normal Cpanel
    systems, both "www.domain.com" and "domain.com" show the same site.

    The only thing that comes to mind without actually looking at the server
    is possibly your DNS zone configuration. You could have a problem with
    your Apache configuration as well but that seems less likely.
     
  4. aaronpie

    aaronpie Member

    Joined:
    Jul 25, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I tried what you suggested but it still does not work. Not sure what is going on.

    Is there something I need to check in the DNS settings?

    - Aaron
     
  5. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Want some help? I'd be glad to take a look around.

    I have seen this complaint twice now but without seeing what is
    going on first hand, I can only guess as to what would be the cause
    but seeing it directly, I could probably tell you in a couple seconds.

    What do you see when you dig your domain name with and without the "www"?

    You don't have a local entry for your domain in the hosts file on your computer do you?
     
    #5 Spiral, Jun 13, 2009
    Last edited: Jun 13, 2009
Loading...

Share This Page