首页 > 技术 > Linux

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

Linux 2022-11-28 12:34:32
复制代码 代码如下:


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

首先,在网站根目录下创建.htaccess文件,在最下面添加写入如下语句:

复制代码 代码如下:

RewriteEngine on
RewriteBase / #我这行是没有配置
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

TAg

加载中~

本网站LOGO受版权及商标保护,版权登记号:国作登字-2022-F-10126915,未经湖南木星科技官方许可,严禁使用。
Copyright © 2012-2022 湖南木星科技有限公司(木星网)版权所有
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源,商业媒体及纸媒请先联系:aishangyiwan@126.com

工信部备案号:湘ICP备19012813号-5