将http和非www重定向到https:// www和子域

时间:2016-09-08 12:28:52

标签: apache .htaccess redirect

我想重定向,因为它位于

之下
  • http必须为https://www.domain.com
  • https://domain.com必须为https://www.domain.com
  • http://www.domain.com必须是https://www.domain.com
  • http://subdomain.domain.com必须为https://subdomain.domain.com

1 个答案:

答案 0 :(得分:0)

请参阅以下htaccess规则

    # 301 --- http://www.domain.com => https://www.domain.com

    RewriteRule ^$ /? [L,R=301]

    # 301 --- https://domain.com => https://www.domain.com

    RewriteCond %{HTTP_HOST} ^domain\.com$
    RewriteRule ^$ https://www.domain.com/? [L,R=301]

    # 301 --- http://subdomain.domain.com => https://subdomain.domain.com

    RewriteRule ^$ /? [L,R=301]