[Resolved] Redirect WebAdmin console to https

#1
Hi,

I've managed to add an web admin console listener with SSL based on a server certificate but now I like to redirect the old http connection to https.
With websites I can do this with htaccess, can I also add this somewhere via terminal?

Kind regards,
Alco
 

NiteWave

Administrator
#2
you can do it via web console:

lsws web admin -> Web Console -> Listeners
-> View/Edit -> Secure: No => Yes, and in SSL tab, fill "Private Key File" and "Certificate File"
 

NiteWave

Administrator
#4
now clear about your question.

I tried to edit /usr/local/lsws/admin/conf/admin_config.xml,
adding following part
Code:
  <rewrite>
    <enable>1</enable>
    <logLevel>0</logLevel>
        <rules>
RewriteCond %{https} !on
RewriteRule /(.*)$ https://%{HTTP_HOST}:7080/$1 [R=301,L]
        </rules>
  </rewrite>
but looks it's completely ignored.
maybe you can try patching /usr/local/lsws/admin/html/index.php
add redirect logic in it.
 
Last edited by a moderator:
#5
Great :)

That solved my question.

I've edited the login.php file in:
Code:
/usr/local/lsws/admin/html/
& added this code on line 1

PHP:
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
  $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  $redirect = str_replace("7080", "7081", $redirect);
  header('HTTP/1.1 301 Moved Permanently');
  header('Location: ' . $redirect);
  exit();
}
 
Last edited by a moderator:
#8
Hi there,
I have recently got ssl for my blog, now I want to redirect all the traffic from http to https. I have tried so many line of codes that is on the internet but none of them really helped. I'm not a very techi guy and really need help.

Here is the code I have tried on htaccess file.
rewriteCond %{HTTPS} !on
rewriteCond %{HTTP:X-Forwarded-Proto} !https
rewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

I'd appreciated if you could help.
Thanks
 

Unique_Eric

Administrator
Staff member
#9
Hi zaggor,
I tried to add this in to OpenLiteSpeed Admin Console>Virtual Hosts > Rewrite > Rewrite Rules, and it works for me:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

Which LSWS edition are you using?
Also just make sure you have enabled Rewrite Rules.
Best.
 
Top