Skip to main content

Redirect http to https in WHM

Comments

6 comments

  • cPanelMichael
    Hello, You can actually add the following entry to the .htaccess file within the account's home directory:
    RewriteEngine On RewriteCond %{SERVER_PORT} !=443 RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteRule ^$ https://www.example.com/%{REQUEST_URI} [R,L]
    This is easier for the end-user to modify should they decide to change this behavior in the future. Thank you.
    0
  • Edubec
    Thanks Michael !
    0
  • neilt17
    Shouldn't that last line be:
    RewriteRule .* https://www.example.com/%{REQUEST_URI} [R,L]
    Rather than:
    RewriteRule ^$ https://www.example.com/%{REQUEST_URI} [R,L]
    which will only redirect the home page but no other pages at www.example.com.
    0
  • cPanelMichael
    Yes, there are several valid alternatives that redirect the pages differently than the example provided. Thank you.
    0
  • aadii786
    This worked to me ::)
    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
    0
  • cPRex Jurassic Moderator
    @aadii786 -it's important to note that your change would affect all the vhosts on the system, instead of just one individual domain. If you want that behavior, that's fine, but I just wanted to mention that.
    0

Please sign in to leave a comment.