我是靠谱客的博主 舒心电源,这篇文章主要介绍Apache配置http访问转https,现在分享给大家,希望可以做个参考。

默认情况下,apache的80端口网站目录是/var/www/html

查找配置文件并修改/etc/httpd/conf/httpd.conf

利用伪静态功能

<Directory "/var/www/html">

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


然后在需要跳转的网站根目录,也就是80端口的网站根目录/var/www/html下创建一个 .htaccess文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可
RewriteEngine on
RewriteBase / 
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
保存,重启httpd服务,再次访问http://域名,发现会直接跳转到https://域名
配置成功。

最后

以上就是舒心电源最近收集整理的关于Apache配置http访问转https的全部内容,更多相关Apache配置http访问转https内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(113)

评论列表共有 0 条评论

立即
投稿
返回
顶部