本文介绍了htaccess将域名重定向到https,将子域名重定向到https,将非www重定向到www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在这样做:
为我的主域强制使用https。
Force the https for my main domain.
http到 https:// www 。 http:// www 到 https:// www 。
但不适用于子域
subdomain.domain 到 subdomain.domain
有人可以帮我吗?
推荐答案您可以在根目录 .htaccess 中使用它:
You can use that in your root .htaccess:
RewriteEngine on # redirect to https www RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)(domain\)$ [NC] RewriteRule ^ www.%1%{REQUEST_URI} [R=301,L] RewriteCond %{HTTP_HOST} ^(domain\)$ [NC] RewriteRule ^ www.%1%{REQUEST_URI} [R=301,L] # redirect to http subdomain RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^((?!www).+\.domain\)$ [NC] RewriteRule ^ %1%{REQUEST_URI} [R=301,L]RewriteEngine on # redirect no-www to www only main domain, not with subdomain RewriteCond %{HTTP_HOST} ^(domain\)$ [NC] RewriteRule ^ www.%1%{REQUEST_URI} [R=301,L] # redirect http to https all domain RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI} [R=301,L]
更多推荐
htaccess将域名重定向到https,将子域名重定向到https,将非www重定向到www
发布评论