zoukankan      html  css  js  c++  java
  • apache 怎么 强制访问https 强制从http转到https

    phpstudy apache 如何 强制访问https?从访问http强制转到https?

    先介绍下环境:
    Windows Server 2012 R2 数据中心版
    phpstudy 集成的 apache和php

    第一步:修改conf/httpd.conf
    在服务器的httpd.conf文件中开启重写.htaccess的权限

    用notepad++打开apache配置文件httpd.conf

    找到下面这一行然后 把前面的#去掉
    LoadModule rewrite_module modules/mod_rewrite.so

    再查找 <Directory ".htaccess文件所在路径">下面的
    AllowOverride None 把它修改为 AllowOverride All

    在网站根目录(WWW)下新建.htaccess
    首先建立一个txt文件另存:格式:全部文件,名称:.htaccess

    然后在.htaccess文件的开始添加 Options +FollowSymLinks

    这是因为在某些服务器配置中,mod_rewrite要求有followsymlinks,否则会显示500内部服务器错误。

    并在后面加入

    RewriteEngine on
    RewriteBase /
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
    必须将代码放到.htaccess文件内容的最前面,以保证重定向优先权。
    ————————————————

    原文链接:https://blog.csdn.net/qq_34626094/article/details/112254740

  • 相关阅读:
    c++ 队列
    17:特殊类成员:函数指针5
    c++ deque 双端队列
    18:字符串-char型字符串
    c++ 16 this 和 继承 及继承机制中的构造函数 与 析构函数
    c++ string char* const char*
    c++ 小片段
    google protobuf 使用示例
    hibernate-cache
    hibernate-criteria查询(二)
  • 原文地址:https://www.cnblogs.com/MR-ws/p/14930543.html
Copyright © 2011-2022 走看看