CyberPanel Community

Redirect HTTP (80) to HTTPS (443)

aa
aaronlroberts #1

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!
3 replies
ba
baoang #2

an easier one here.

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

First, make sure the LoadModule line for mod_rewrite is uncommented in the httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

Next, add the following to the global scope or any port 80 VirtualHost stanzas defined within the httpd.conf configuration file.

RewriteEngine on
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.)*** https:// **%{SERVER_NAME}%{REQUEST_URI} [R,L]

Bl
Bl0ck #8

it’s doesn’t work to me, should I restart something to have a result?

Sign in to reply