华域联盟 Linux 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]

您可能感兴趣的文章:

本文由 华域联盟 原创撰写:华域联盟 » apache设置自动将http跳转到https的方法

转载请保留出处和原文链接:https://www.cnhackhy.com/45396.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部