将所有无 http 请求重定向到 https+www,子域除外
Redirect all no http request to https+www except subdomains
我在为正确的重定向创建 .htaccess 文件时遇到了一些问题。
我需要使用 www 将所有请求重定向到 https,子域除外。
场景是这样的:
http://example.com-> https://www.example.com
https://example.com-> https://www.example.com
http://www.example.com-> https://www.example.com
http://subdomain.example.com-> http://subdomain.example.com[unchanged]
or
http://subdomain.example.com-> https://www.example.com/sites/subdomain
非常感谢任何帮助。
在文档根目录的 htaccess 文件中,将其添加到顶部:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/ [L,R=301]
我在为正确的重定向创建 .htaccess 文件时遇到了一些问题。 我需要使用 www 将所有请求重定向到 https,子域除外。
场景是这样的:
http://example.com-> https://www.example.com
https://example.com-> https://www.example.com
http://www.example.com-> https://www.example.com
http://subdomain.example.com-> http://subdomain.example.com[unchanged]
or
http://subdomain.example.com-> https://www.example.com/sites/subdomain
非常感谢任何帮助。
在文档根目录的 htaccess 文件中,将其添加到顶部:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/ [L,R=301]