Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to redirect from domain.com to www.domain.com

Discussion in 'General Discussion' started by silis25, Sep 20, 2011.

  1. silis25

    silis25 Member

    Joined:
    Jul 7, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    51
    Hi,

    I need your assistance in redirecting my domain properly.

    Problem: My domain 'letthemstare.com' doesn't redirect to 'www.letthemstare.com'

    'www.letthemstare.com' - Works
    'letthemstare.com' - Fails

    1. My site is located within a folder named fashionblog.
    2. I modified my httpd.conf through "Pre VirtualHost Include" as follows:

    <Directory /home/letthems/public_html>

    # Turn on rewrites.
    RewriteEngine on

    # Only apply to URLs on this domain
    RewriteCond %{HTTP_HOST} ^(www.)?letthemstare.com$

    # Only apply to URLs that aren't already under folder.
    RewriteCond %{REQUEST_URI} !^/fashionblog/

    # Don't apply to URLs that go to existing files or folders.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Rewrite all those to insert /fashionblog.
    RewriteRule ^(.*)$ /fashionblog/$1

    # Also redirect the root folder.
    RewriteCond %{HTTP_HOST} ^(www.)?letthemstare.com$
    RewriteRule ^(/)?$ fashionblog/index.php [L]

    </Directory>

    The above redirects most of the things properly but letthemstare.com redirection still doesn't work.

    4. Also, I don't understand why

    RewriteCond %{HTTP_HOST} ^letthemstare.com$

    doesn't redirect my domain (I've tried that)

    I will appreciate your help here.

    Kfir Silis
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Have you tried simply putting in an .htaccess file in /home/username/public_html/.htaccess location with these rewrites? There's no real reason to use an include for these. You might try the following instead for that redirection:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^letthemstare.com
    RewriteRule (.*) http://www.letthemstare.com/$1 [R=301,L]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. AunRaza

    AunRaza Member

    Joined:
    Feb 4, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    51
    More simple way will be to add this redirect via cpanel's Redirect menu :)
     
  4. mambovince

    mambovince Well-Known Member

    Joined:
    Jan 15, 2005
    Messages:
    193
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    London, UK
    I am surprised cPanel does not yet include a simple option to do this yet.

    BTW
    is there any difference on how to write that last rule:
    RewriteRule (.*) http://www.letthemstare.com/$1 [R=301,L]
    I was previously told this way
    RewriteRule (.*) http://www.letthemstare.com/$1 [L,R=301]

    Thanks
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #4 mambovince, Nov 30, 2011
    Last edited: Nov 30, 2011
  5. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    168
    I'm going to ask a silly question here: is 'letthemstare.com' supposed to point to the exact same content as 'www.letthemstare.com'?? If so, and your DNS is setup correctly, all you need is a simple redirect configured in the cpanel redirect section...

    Edit: it looks like it's working when I visit the site, assuming I'm supposed to see some rather hottish pics ;-)
     
    #5 Lyttek, Nov 30, 2011
    Last edited: Nov 30, 2011
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice