什么是最有效的code检测和重定向SNI支持的浏览器? [英] What is the most efficient code to detect and redirect SNI supported browsers?

查看:286
本文介绍了什么是最有效的code检测和重定向SNI支持的浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说,我有一个网站 mywebsite.com ,使用Apache的httpd主办。现在我想的是,只要任何用户类型 mywebsite.com www.mywebsite.com ,如果浏览器支持SNI那么它应该重定向到 https://www.mywebsite.com 其他重定向到 http://www.mywebsite.com

Say, I have a website mywebsite.com, hosted using Apache Httpd. Now what I want is that whenever any user types mywebsite.com or www.mywebsite.com and if the browser supports SNI then it should redirect to https://www.mywebsite.com else redirect to http://www.mywebsite.com.

那么,什么是实现这一目标的最有效方法是什么?

So, what is the most efficient way to achieve it ?

推荐答案

以下code应该

Options -Indexes +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^mywebsite.com$
RewriteCond %{HTTPS} (on|off)
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=302,L]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !MSIE\s6
RewriteCond %{HTTP_USER_AGENT} !Windows\sNT\s5
RewriteCond %{HTTP_USER_AGENT} !^(.*.symbian.*) [NC]
RewriteCond %{HTTP_USER_AGENT} !^(.*.blackberry.*) [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=302,L]

下面我们忽略大部分不支持SNI,因此对他们来说仅HTTP版本将被加载的浏览器。

Here we are neglecting most of the browsers which does not support SNI and hence for them only the http version would be loaded.

这篇关于什么是最有效的code检测和重定向SNI支持的浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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