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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Global https and non www not in htaccess

Discussion in 'Bind / DNS / Nameserver Issues' started by stapuff106, Oct 2, 2017.

  1. stapuff106

    stapuff106 Member

    Joined:
    Aug 4, 2017
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Chicago
    cPanel Access Level:
    Root Administrator
    In Home »Service Configuration »Apache Configuration »Include Editor

    Under Pre Main Include I select All Versions, which gives me Global input

    I added the following which redirects all to https.
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    
    I added the following to go from www to non-www, but is does not work.
    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} !=on
        RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
        RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
    </IfModule>
    
    The net of this is I want all traffic sent to https and non-www for all the domains on the server.

    Any suggestions,

    Thanks stapuff106
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,424
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page