apache设置自动将http跳转到https的方法

apache设置自动将http跳转到https的方法

复制代码 代码如下:
<Directory "/opt/fivetrees">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All #这里原先是None要改为All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>

首先。在网站根目录下创建.htaccess文件。在最下面添加写入如下语句:

复制代码 代码如下:
RewriteEngine on
RewriteBase / #我这行是没有配置
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

分享到 :
相关推荐

香港云虚拟机网速怎么样(香港云虚拟机网速怎么样啊)

香港云虚拟机网速正常的ping值一般在50ms左右。速度相对比较快的。对于国内用户而...

站群服务器是怎么样的(什么是站群服务器)

什么叫站群服务器?公司或客户要是想建立好几个网址得话。就必须采用站群服务器。说白了站...

云主机的优缺点是什么(云主机的优缺点是什么意思)

具体内容如下:一。优点使用云服务器的用户可以在上面自由安装操作系统。具有非常高的[&...

租用不实名香港云服务器CN2线路有哪些优势(香港cn2云主机)

租用不实名香港云服务器CN2线路的优势有:1。访问速度快。具备平稳升级到IPv6的潜...

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注