How to Redirect the Domain from HTTP to HTTPS with www

To redirect all website requests to the domain with the www prefix and enforce https at all times, follow these steps:

  1. Access the main directory of your website (public_html), then edit the .htaccess file and add the following settings:

Force the domain to use www:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

Force the domain to use https:


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

Force the domain to use both www and https:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

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

After finishing, save the changes.

Note: If the .htaccess file doesn’t exist, you can create a new one inside the public_html directory, add the settings above, and save the file.

Was this answer helpful?

Related Articles

طريقة انشاء نسخة احتياطية لموقعك

هذة الطريقة الصحيحة لاخذ النسخة الاحتياطية ولاننصح بغيرهااولاً الدخول الى لوحة التحكم Cpanelثم...

How to Add Your Custom Email to Outlook

First, create the email you want to add (see how here). Open Outlook, then from the...

كیفیة الدخول الى لوحة تحكم الموقع (Cpanel)

يمكنك تسجيل الدخول إلى لوحة تحكم الموقع سي بانل عن طريق الرابط التالي:https://domain.com:2083مع...

كيفية الدخول وادارة الحساب البريدي Email Account الخاص بالموقع

بعد انشاء الحساب البريدي بأتباع التعليمات التالية : اضغط هنا يمكنك الدخول الى البريد الخاص بك...

كیفیة انشاء جدار نارى على مجلد او كیفیة حمایة مجلد بكلمة مرور من خلال Cpanel

لحماية مجلد من خلال لوحة التحكم سي بانل يرجى اتباع الخطوات التالية: 1. قم بتسجيل الدخول إلى...