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!

Global https and non www not in htaccess

Discussion in 'Bind/DNS/Nameserver' 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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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