[英]How to redirect HTTPS non-www to HTTPS www using .htaccess?
[英]Using .htaccess to redirect www URLs to non-www for https
请为我提供 .htaccess 语法以执行以下操作:
我尝试了以下但没有奏效:
RewriteCond %{HTTP_HOST} ^www.(.*)
重写规则 ^.*$ https://%1/ $1 [R=301,L]
尝试将以下内容添加到域根文件夹中的 htaccess 文件中。
RewriteEngine on
RewriteBase /
#if not domain.com.uk then redirect to domaim.com.uk
RewriteCond %{HTTP_HOST} !^domain\.com\.uk$ [NC]
RewriteRule .* http://domain.com.uk%{REQUEST_URI} [L,R=301]
#if not https
RewriteCond %{HTTPS} off
#redirect to https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com.uk
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://domain.com.uk/$1 [R=301,L]
对我来说这项工作,刚刚测试。 所以http://www.domain.com.uk into https://domain.com.uk
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.