首先apache已经打开了伪静态模块,然后在apache的主配置文件里面进行设置,设置根目录

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

然后再打开http网站试一下是否已经跳转到了https了呢

分享该文章:

相关文章:

  • 暂无相关文章