apahce2.2 http https ssl/tls 加…
来源:互联网 发布:linux free m 详解 编辑:程序博客网 时间:2024/06/07 00:56
如何设置http自动跳转到https?apache环境下,配置好https后,需要设置url重定向规则,使网站页面的http访问都自动转到https访问。
1)打开Apache/conf/httpd.conf,找到 #LoadModule rewrite_modulemodules/mod_rewrite.so 去掉#号。
2)找到你网站目录的段,比如我的网站目录是c:/www,找到
…
修改其中的 AllowOverride None 为 AllowOverrideAll3)重启apache服务2、设置重定向规则
1)在你网站目录下放一个.htaccess文件。windows环境下,不能把文件直接改名为.htaccess,会提示你必须输入文件名。所以我们先新建一个“新建文本文档.txt”文档,记事本打开,选择另存为,保存类型选择“所有文件(*.*)”,文件名输入“.htaccess”,保存。这样便生成了一个.htaccess文件。
2)编辑器打开.htaccess文件,写入如下规则:
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^/tz.php
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]
解释:
%{SERVER_PORT} —— 访问端口
%{REQUEST_URI} —— 比如如果url是 http://localhost/tz.php,则是指/tz.php
%{SERVER_NAME} —— 比如如果url是 http://localhost/tz.php,则是指localhost
以上规则的意思是,如果访问的url的端口不是443,且访问页面不是tz.php,则应用RewriteRule这条规则。这样便实现了:访问了http://localhost/index.php 或者 http://localhost/admin/index.php等页面的时候会自动跳转到 https://localhost/index.php 或者https://localhost/admin/index.php,但是访问 http://localhost/tz.php的时候就不会做任何跳转,也就是说 http://localhost/tz.php 和 https://localhost/tz.php两个地址都可以访问。
- apahce2.2 http https ssl/tls 加…
- check_http: Invalid option - SSL…
- apache http ssl模块NoC…
- linx IPSec PPP CIPE SSL VPN PPPT…
-  
- 集线器 交换机 路由器 网桥 …
-
- 使用BBED修改SCN …
- tcp udp http
- Hive安装 …
- android o…
- android …
- [转] 彼尔…
- “constructors not allowed …
- 关于alter system switch lo…
- POJ 1503 Integer Inquiry(大数加…
- Http Persistent Link (http 1.1 n…
- Struts 2 + Spring 2.0 + Hibernat…
- 第3章数据和C
- H3C路由器配置
- MyBatis框架环境搭建以及配置
- ubuntu停止httpd服务
- 项目中遇到的单词.句子.积累
- apahce2.2 http https ssl/tls 加…
- ios andior pc使用数据库的存储路径
- BGP3
- linux的文件打包与压缩
- Multicast-1
- 华为USG配置案例
- 强叔侃墙 安全策略篇 AS…
- 【拼多多2018校招内推】【编程题】【最大乘积】【大整数相乘】
- LoadRunner安装+汉化+破解