apache设置自动将http跳转到https的方法
程序员文章站
2023-11-16 09:02:04
复制代码 代码如下:## possible values for the options directi...
复制代码 代码如下:
<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]
上一篇: 解决Unixbench安装报错信息的问题
下一篇: 用CSS开发时髦的导航栏第二篇