[英]redirect http://www.domain.com to https://domain.com
[英]Redirect http://www.domain.com to https://www.domain.com using .htaccess
我想将我的域从http重定向到https:
http://www.domain.com --> https://www.domain.com
可能吗? 我一直在互联网上搜索,但只发现:
http://domain.com --> https://www.domain.com
问题是,人们如何直接到达http://www.domain.com ? 他们不是通过非https网址投放吗? 反之亦然。 我只想简单地从HTTP重定向到HTTPS。 可能吗?
谢谢
I just want a simple redirection from the HTTP to HTTPS
尝试将此简单规则作为您的.htaccess的第一条规则 :
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
使用以下代码强制使用www和SSL:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
它将适用于所有版本的php,并将SSL和www强制应用于所有裸域和链接:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off # Now, rewrite any request to the wrong domain to use www. RewriteCond %{HTTP_HOST} !^www\\. RewriteCond %{HTTP_HOST} ^tatwerat\\.com [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} </IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.