当前位置: 移动技术网 > 网络运营>服务器>Linux > apache设置自动将http跳转到https的方法

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

2019年05月03日  | 移动技术网网络运营  | 我要评论

复制代码 代码如下:

<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]

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网