Community

Http request does not redirect to Https

Ru
Runo #1

Hello,

My website works fine with https, but when I log in with http, https does not redirect.

I noticed something, the website public_html file is located in both root folder and home folder.
I add the standard redirect code to the .htaccess file but it doesn’t work at all.

Can you help me how to edit the vhost.conf and make the root part home/domainname/public_html?

I think the problem is with the Vhost Conf docRoot setting.

Ru
Runo #3

@josephgodwinke

Hello,
I shared below. Thank you from now.

jo
josephgodwinke #4

You modified the default rule from cyberpanel

It should be

RewriteEngine On
RewriteCond %{HTTPS}  !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Ru
Runo #5

Yes I made the change but the problem still persists. I did sysctemctl resrtart lsws and even restarted the server.

jo
josephgodwinke #6

Try this


RewriteEngine on
# match query string params in any order
RewriteCond %{QUERY_STRING} ^$
# internal rewrite
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# L for match path case insensitive
Ru
Runo #7

Sorry sir, that didn’t work either.

jo
josephgodwinke #8

Anyway this should work

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I dont understand how that doesnt work. Did you change anything in your ols/ls config for this virtual host also run a cyberpanel update

sh
shoaibkk #9

add forcefully https redirect rules and then restart webserver as well should work

Ru
Runo #10

Thank you for your comments. First of all, I will update Cyberpanel. Then I will try the steps you said again.

Ru
Runo #11

@josephgodwinke @shoaibkk
Hello again,

I updated the Cyber Panel. Again, I added the forced https redirection from the Rewrite Rules section in CyberPanel. But nothing changed.

The website works with https:// but when it sends a request with http:// it gives a time out error.

jo
josephgodwinke #12

Post screenshot of the error when you visit the webpage

Ru
Runo #15

Thanks for help. We gave up on CyberPanel and quickly solved the problem with another panel. You can close the topic. have a nice day.

Sign in to reply