How to http to https force redirect a ChildDomain

I have a ChildDomain installed
SSL is installed, but HTTP to HTTPS is not redirecting.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I have added this redirection rule, but not working

http://app.mydomain.com to https://app.mydomain.com - this is what I want.

FYI: It’s a Laravel installation.

Happy New Year @shankha

Try adding this to Websites > List Websites > mydomain.com > Child Domains > app.domain.com > Rewrite Rules

RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://app.mydomain.com/? [R=301,L]

I applied it,
But not working!!!

Also checked via HTTPS (SSL) Redirect Checker - SEOptimer, it shows Your page does not redirect to a HTTPS (SSL secure) version.

Try with HTTP_HOST instead of Query string

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

This is how it looks now.

RewriteEngine on

# Redirect Trailing Slashes If Not A Folder...

RewriteCond %{REQUEST_FILENAME}!-d

RewriteCond %{REQUEST_URI} (.+)/$

RewriteRule ^ %1 [L,R=301]

RewriteCond %{REQUEST_URI} !^public

RewriteRule ^{.*)$ public/$1 [L]

RewriteEngine on

RewriteCond %{HTTP_HOST} childdomain.com [NC,OR]

RewriteCond %{HTTP_HOST} ^app.childdomain.com [NC]

RewriteRule ^(.*)$ https://app.childdomain.com/$1 [L,R=301,NC]

Still not redirectiong to https!!!

Why do you need the first conditions for lookin up index.php in documentroot when you have a condition to tell lsws to run any files from public/ ?

You also have other conditions for a subdomain below all those conditions. This is not the way!

Create a separate child domain or subdomain OR create a website with the subdomain and force ssl on it. Cyberpanel already has a preselect rule for HTTP to HTTPS. click on it and you are a go

I added this rewrite rule option under the childDomain > Manage > Rewrite rules,
not under the root domain.

Delete every rule there and these How to http to https force redirect a ChildDomain - #4 by josephgodwinke

Make sure you have placed all public files under /home/childomain.com/public_html/

Not working, If I remove everything and put those only, I am getting app.childdomaincom/404.html

Delete every rule

Try adding this to Websites > List Websites > mydomain.com > Child Domains > app.domain.com > Rewrite Rules

### Rewrite Rules Added by CyberPanel Rewrite Rule Generator

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

### End CyberPanel Generated Rules.

1 Like

if I am deleting this rule, I am getting ERR_TOO_MANY_REDIRECTS

RewriteRule ^(.*)$ public/$1 [L]

I would point where the served files are using vHost Conf

docRoot                   $VH_ROOT/public_html/public

To go further If my index file is different I would change

index  {
  useServer               0
  indexFiles              server.php, index.html
}
1 Like

Now it works, thanks!!!