使用.htaccess将所有子域从http重定向到https [英] redirect all subdomains from http to https using .htaccess

查看:75
本文介绍了使用.htaccess将所有子域从http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 example.com 的所有子域从 http 重定向到 https 使用 .htaccess

How do I redirect all subdomains of example.com from http to https using .htaccess?

我已经搜索过Google,但找不到解决方案。

I've searched Google and can't find a solution.

推荐答案

要将 example.com 的所有子域重定向到 https ,您可以使用:

To redirect all subdomains of example.com to https , you can use :

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+)\.example\.com$
RewriteRule ^ https://%1.example.com%{REQUEST_URI} [NE,L,R]

这篇关于使用.htaccess将所有子域从http重定向到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆