Redirect HTTP (80) to HTTPS (443).

If you have successfully set up an SSL certificate for a domain, you will need to add a rewrite rule to that website in order to have it automatically forward to HTTPS instead of HTTP - otherwise you will have 2 versions, potentially damaging your SEO and encounter other issues.

To do this:

  1. Login to CyberPanel
  2. Select Websites on the left menu
  3. Choose the SSL enabled website from the list
  4. Select “Rewrite Rules” in the Configuration section
  5. Copy and paste the following code:

rewriteCond %{HTTPS} !on
rewriteCond %{HTTP:X-Forwarded-Proto} !https
rewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

  1. Now just save your changes, and you’re done!

an easier one here.

RewriteCond %{SERVER_PORT} ^80$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]