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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-18 我要评论
想了解apache设置自动将http跳转到https的方法的相关内容吗,在本文为您仔细讲解http跳转到https的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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]

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们