我在创建.htaccess文件以进行正确重定向时遇到了一些问题。我需要重定向所有请求到https与www除了子域。
这是一种情况:
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/$1 [L,R=301]