复制代码 代码如下:
<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]
您可能感兴趣的文章:
- apache https配置详细步骤讲解
- Apache mod_rewrite实现HTTP和HTTPS重定向跳转
- 阿里云服务器apache配置SSL证书成功开启Https(记录趟过的各种坑)
- Apache由http自动跳转到https的多种方法
- Apache使用 .htaccess 来实现强制https访问的方法
- apache中使用mod_gnutls模块实现多个SSL站点配置(多个HTTPS协议的虚拟主机)
- 详解在Ubuntu上的Apache配置SSL(https证书)的正确姿势
- IIS与APACHE实现HTTP重定向到HTTPS
- Linux环境下Apache开启https服务的方法详解
本文由 华域联盟 原创撰写:华域联盟 » apache设置自动将http跳转到https的方法
转载请保留出处和原文链接:https://www.cnhackhy.com/45396.htm