LiteSpeed Redirect Traffic To HTTPS with CyberPanel

LiteSpeed Redirect Traffic To HTTPS

To redirect traffic from http to https, you can use rules that are the same as you would use in that of apache. So, for example, the below rules will help in https redirection

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

If you are using CyberPanel, then you can edit the rules by going to your individual web panel for your domain, and clicking Rewrite Rules as shown below.

CyberPanel Rewrite Rules

After clicking it, I suggest you put the rule at the top of the file so that the redirection is processed before any other rule.CyberPanel Rewrite Rules FileAfter which, you just have to save the new rules and your good to go.CyberPanel Rewrite Rules Save

 

Enjoyed the content ? Share it with your friends !

Redirect http to https with htaccess

Redirect http to https with htaccess

Here’s how you can redirect http to https by manually editing your .htaccess¬†file. This will allow you to avoid the need for plugins or the like, while also giving you more control of what you want redirected.

Redirect all HTTP traffic to HTTPS 

# BEGIN HTTPS REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS REDIRECT

Redirect a subfolder or directory only

# BEGIN HTTPS REDIRECT
# edit 'www.example.com' and the subdirectory (the two 'secure')
<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{SERVER_PORT} !^443$ 
RewriteCond %{REQUEST_URI} secure 
RewriteRule ^(.*)$ https://www.example.com/secure/$1 [R,L]
</IfModule>
# END HTTPS REDIRECT

 

This should work fine on both apache, and litespeed, since both supports the mod_rewrite module

Enjoyed the content ? Share it with your friends !