如何强制将子域重定向到“ https:// www。”?

时间:2020-11-01 17:52:22

标签: regex apache .htaccess redirect https

我要重定向

  1. geom_hline(aes(yintercept = df %>% filter(sample_name="control1") %>% select("upper_limit_value"))) + geom_hline(aes(yintercept = df %>% filter(sample_name="control1") %>% select("lower_limit_value")))

  1. http://sub.domain.com

  1. http://www.sub.domain.com

  • https://sub.domain.com

如何在.htaccess中执行此操作? 预先感谢。

还有一个额外的问题,我在哪里可以学到这些?有必要学习吗?

[您可以说网络上有很多答案,但是大多数答案是针对主域的,而不是针对子域的。]

1 个答案:

答案 0 :(得分:2)

您可以使用:

RewriteEngine on

# Redirect sub.domain.com to https://www.sub.domain.com
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^ https://www.sub.domain.com%{REQUEST_URI} [NE,R=301,L]

# Redirect http://www.sub.domain.com to https://www.sub.domain.com
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.sub\.domain\.com$ [NC]
RewriteRule ^ https://www.sub.domain.com%{REQUEST_URI} [NE,R=301,L]

您可以在此处学习Apache配置格式:https://httpd.apache.org/docs/mod/mod_rewrite.html

相关问题