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!

.htaccess redirect

Discussion in 'General Discussion' started by 'Giovanni, Apr 16, 2014.

  1. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    I want to do a .htaccess redirect from https to http and from non www to www, can anyone help me with the correct code?
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    834
    Likes Received:
    28
    Trophy Points:
    178
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    To force http:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
    
    To force www:

    Code:
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{http_host} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    Please follow the steps listed in the previous post. Feel free to let us know the outcome.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    It does the redirect on http from non www to www but on ssl if i access https:// domain.com it redirects me to another domain (not domain.com) and for https:// www. domain.com it shows the warrning atempt reach etc. and if i proceed, again goes to other domain

    :confused:
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    Are you sure a valid SSL certificate has been installed for this domain name, and it's not utilizing another certificate for another domain on a shared IP address?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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