Community

Closed SSL not working for non https URL

OO
Oluwatobi Owolabi #1

I have SSL issued to website and when https://website.tld is visited it work but does not for www.website.tld or website.tld

Can some help me to resolve this.

NK
Nitesh Kunnath #2

You need to add redirect code in your htaccess file

If you want your domain to be with www, use this below code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.
)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you want your domain to be visited without www, then use this below code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.
)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

OO
Oluwatobi Owolabi #4

Is there a way I can do this maybe through CLI? I am unable to find the .htaccess file in the file manager, I guess a feature to show hidden files will be needed for file manager.

NK
Nitesh Kunnath #5

Filemanager shows hidden files too in Cyberpanel by default. Infact there is no option I see to hide hidden files :rofl:

Just create new file named .htaccess and then copy paste the code I provided in previous message.

This topic is closed to new replies.