IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

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

    Vlix_Liu发表于 2014-12-31 07:23:28
    love 0

    利用伪静态功能

        #

        # 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文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可

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


沪ICP备19023445号-2号
友情链接