انتقل إلى المحتوى

الدروس الأمان مبتدئ1 دقائق قراءة

How to Force HTTPS and Redirect All Traffic to SSL

Redirect every visitor from HTTP to HTTPS with cPanel’s Force HTTPS setting or .htaccess, choose www or non-www, and add HSTS safely.

بواسطة فريق تحرير ZSOLNET آخر تحديث

هذه الصفحة غير متاحة بالعربية بعد، لذا تُعرض بالإنجليزية.

أهم النقاط

  • Use one permanent redirect from HTTP to HTTPS.
  • Behind a CDN, redirect at the CDN to avoid loops.
  • Roll out HSTS with a short max-age first.

Once your site has an SSL certificate, send every visitor to the secure version with a single permanent redirect.

Option 1: cPanel

Open Domains, find the domain and switch on Force HTTPS Redirect. The toggle is only available when the domain has a valid certificate.

Option 2: .htaccess

Add this near the top of .htaccess in the document root:

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

To also standardise on the bare domain in one hop:

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

WordPress

Also update Settings → General so both addresses start with https://, then fix any mixed content.

Add HSTS (optional)

HTTP Strict Transport Security tells browsers to always use HTTPS for your domain:

Header always set Strict-Transport-Security "max-age=31536000"

Start with a short max-age (such as 300) to test, and only add includeSubDomains once every subdomain supports HTTPS.

شارك X LinkedIn Facebook

الدخول إلى حسابك

أدِر نطاقاتك واستضافتك وفواتيرك من مكان واحد.

اتصال آمن مباشرة مع منطقة العملاء في ZSOLNET.

افتح لوحة تحكم ZSOLNET

ليس لديك حساب؟