Knowledgebase

How to redirect user from none www http to www https ?

Scenario:

You want to force all users/client to access your website using https instead of http.

Requirement:
  1. If you do not have a valid SSL Certificate, you will need to buy it. You can check the price here  if you would like to buy it from us. Once you have your own SSL Certificates you will need to installed it at your cPanel account. If you already have one, you can install it directly to your cPanel account.
  2. Make sure your SSL Certificate that you are going to install onto your cPanel has your domain as the CN info. else, you will get SSL Certificate error notification.
Solutions:

You will need to add below script into your .htaccess

    1. Login to your cPanel and click on the File Manager > make sure you tick on "Show hidden files".
    2. Go to your public_html folder and find .htaccess file.
    3. Select .htaccess file and right click on it. Please select Edit option or Code edit option.
    4. Now it will open a new tab with contents inside your .htaccess file.
    5. Copy below script and paste it inside your .htaccess
      <IfModule mod_rewrite.c>
      RewriteCond %{HTTP_HOST} !^www\.
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1
      </IfModule>
    6. Click save button and test it.
Notes:
    You can custom the script above to fit with your requirement.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Installation error cause by PHP disable functions

Issue:Receive errors when trying to install new CMS(Content Management Systems) which saying that...

Files fail FTP transfer

When uploading many files at once (a CMS, for example), it is not uncommon for a few of the files...

I'm receiving a blank page

If your website or web application is displaying nothing but a blank, white page, then chances...

How do I configure hotlink protection?

Login to cPanel. Locate and click on the "Hotlink Protection" icon within the "Security"...

Email Protection using RBL (Real-time Block List)

We at myduniahosting always strive to make sure that our email services are always protected from...