Apache RewriteHTTPToHTTPS
HTTP to HTTPS
Scenario :
You want to force people coming to your site to use HTTPS. Either for the entire site or a small sub-section of it.
Note
Using mod_rewrite to do this isn't the recommended behavior. See RedirectSSL
Fix :
RewriteEngine On
# This will enable the Rewrite capabilities RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
Entire site (.htaccess) :
Note: While the rules you need are the same as above (because the rule above doesn't depend on any of the quirks of rewrite in .htaccess), you will need to ensure that you place this in a .htaccess file in the root of the site you want to apply it against, and to make sure you have the appropriate AllowOverride configuration in your httpd.conf
Specific Directory
Either put the above solution in a .htaccess file in the directory to be affected, or put the URI prefix in the regex itself.
RewriteEngine On
# This will enable the Rewrite capabilities RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS RewriteRule ^/?secure/(.*) https://%{SERVER_NAME}/secure/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
# i.e. http://www.example.com/secure/ to https://www.example.com/secure/
# This means if you dont want to force HTTPS for all directories you can force it for a specific sub-section of the site.
Apache RewriteHTTPToHTTPS的更多相关文章
- Apache执行Python脚本
由于经常需要到服务器上执行些命令,有些命令懒得敲,就准备写点脚本直接浏览器调用就好了,比如这样: 因为线上有现成的Apache,就直接放它里面了,当然访问安全要设置,我似乎别的随笔里写了安全问题,这里 ...
- Apache Ignite之集群应用测试
集群发现机制 在Ignite中的集群号称是无中心的,而且支持命令行启动和嵌入应用启动,所以按理说很简单.而且集群有自动发现机制感觉对于懒人开发来说太好了,抱着试一试的心态测试一下吧. 在Apache ...
- Apache Ignite高性能分布式网格框架-初探
Apache Ignite初步认识 今年4月开始倒腾openfire,过程中经历了许多,更学到了许多.特别是在集群方面有了很多的认识,真正开始认识到集群的概念及应用方法. 在openfire中使用的集 ...
- Apache 与 php的环境搭建
Apache和PHP的版本分别为: httpd-2.4.9-win64-VC11.zip php-5.6.9-Win32-VC11-x64.zip 下载地址: php-5.6.9-Win32-VC11 ...
- Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
学习架构探险,从零开始写Java Web框架时,在学习到springAOP时遇到一个异常: "C:\Program Files\Java\jdk1.7.0_40\bin\java" ...
- 【开发软件】 在Mac下配置php开发环境:Apache+php+MySql
本文地址 原文地址 本文提纲: 1. 启动Apache 2. 运行PHP 3. 配置Mysql 4. 使用PHPMyAdmin 5. 附录 有问题请先 看最后的附录 摘要: 系统OS X ...
- Apache Cordova开发Android应用程序——番外篇
很多天之前就安装了visual studio community 2015,今天闲着么事想试一下Apache Cordova,用它来开发跨平台App.在这之前需要配置N多东西,这里找到了一篇MS官方文 ...
- java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE
Android发出HTTP请求时出现了这个错误: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INST ...
- Ubuntu下配置apache开启https
一.HTTPS简述随着网络的日常,信息安全越来越重要,传统的网站都是http协议明文传输,而HTTPS协议是由SSL+HTTP协议构建的可进行加密传输.身份认证的网络协议,比http协议安全. 那ht ...
随机推荐
- php 屏蔽NOTICE报错机制代码
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT^E_NOTICE
- ln 命令使用
今天在工作中遇到了“ln -sf”命令,发觉很久没用基本忘光,遂重拾鸟哥神书温补了一把. 简单描述的话,ln是linux中用来链接文件的,存在两种不同的连接: 1) Hard Link 实现该操作很简 ...
- Http协议:彻底弄懂 Http 缓存机制 - 基于缓存策略三要素分解法
转载:http://mp.weixin.qq.com/s/uWPls0qrqJKHkHfNLmaenQ 导语 Http 缓存机制作为 web 性能优化的重要手段,对从事 Web 开发的小伙伴们来说是必 ...
- html框架
1.框架的概念 框架:将一个浏览器窗口划分成若干个小窗口 2.框架集合框架页 框架集<frameset>:主要用来划分窗口的. 框架页<frame>:主要用来指定窗口默认显示的 ...
- css实现自适应屏幕高度;
css实现自适应屏幕高度: <!DOCTYPE html><html lang="en"><head> <meta charset=&qu ...
- Python几种主流框架
从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. Django: Python Web应用开发框架 Djang ...
- u-boot-2010.09移植(A)
第一阶段 1.开发环境 系统:centOS6.5 linux版本:2.6.32 交叉编译器:buildroot-2012.08 以上工具已经准备好,具体安装步骤不再 ...
- sql查询语句
//查询表的字段名和字段类型select column_name,data_type from information_schema.columns where table_name = '表名' / ...
- 触发器事件trigger
修改mysql结束符 delimiter name 触发器语法: create trigger 触发器名称 after/before 触发时间 //错误 ERROR ...
- 《HelloGitHub》之GitHub Bot
起因 我在github上发起了一个开源项目:<HelloGitHub月刊>,内容是github上收集的好玩,容易上手的开源项目. 目的:因为兴趣是最好的老师,我希望月刊中的内容可以激发读者 ...