CyberHosting

HTTP to HTTPS WWW ? How do I achieve it?

Hello guys,

I want to redirect mysite.com to https://www.mysite.com. How do I achieve it? So far, I do have the SSL in place for both https://mysite.com and https://www.mysite.com. Even though I can easily set it to redirect from http://mysite.com to https://mysite.com, I don't want to. I want it to redirect to https://www.mysite.com instead. How do I achieve it?

Comments

  • Rewrite rules. Set it in your manage website panel
    Cyberpanel Managed & Unmanaged Shared & VPS Hosting by Cyberpanel Experts.

    https://www.cyberhosting.org
  • edited November 2019
    When I rewrite the rules it only works for https://mysite.com but breaks my website when I set it to redirect to https://www.mysite.com despite having the site accessible if you directly type https://www.mysite.com on the browser.
  • Depends on what you mean breaks your site. If you are talking about css styling then you need to look at your code for that.

    Google rewrite rules and openlitespeed
    Cyberpanel Managed & Unmanaged Shared & VPS Hosting by Cyberpanel Experts.

    https://www.cyberhosting.org
  • # HTTP to HTTPS redirect
    RewriteCond %{SERVER_PORT} 80
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R,L]

    # Canonical www redirect
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R,L]

    Place on .htaccess file near the top. Make sure to restart your webserver.
  • Numeriku said:

    # HTTP to HTTPS redirect
    RewriteCond %{SERVER_PORT} 80
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R,L]

    # Canonical www redirect
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R,L]

    Place on .htaccess file near the top. Make sure to restart your webserver.

    Thanks for you response. LiteSpeed support gave me the second option it works perfectly.
Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!