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.
时间: 2024-11-10 01:46:11

Apache RewriteHTTPToHTTPS的相关文章

centos7.2 apache开启.htaccess

打开httpd.conf(在那里? APACHE目录的CONF目录里面),用文本编纂器打开后,查找 (1) AllowOverride None 改为 AllowOverride All (2)去掉下面的注释 LoadModule rewrite_module modules/mod_rewrite.so 如果没有发现这句话,代表这句话可能存在在其他文件中,然后被include入配置 可以搜索一下Include conf.modules.d/*.conf 然后可以发现这句话是在conf.modu

Nginx为什么比Apache Httpd高效:原理篇

一.进程.线程? 进程是具有一定独立功能的,在计算机中已经运行的程序的实体.在早期系统中(如linux 2.4以前),进程是基本运作单位,在支持线程的系统中(如windows,linux2.6)中,线程才是基本的运作单位,而进程只是线程的容器.程序 本身只是指令.数据及其组织形式的描述,进程才是程序(那些指令和数据)的真正运行实例.若干进程有可能与同一个程序相关系,且每个进程皆可以同步(循 序)或异步(平行)的方式独立运行.现代计算机系统可在同一段时间内以进程的形式将多个程序加载到存储器中,并借

Apache Storm 1.1.0 中文文档 | ApacheCN

前言  Apache Storm 是一个免费的,开源的,分布式的实时计算系统. 官方文档: http://storm.apache.org 中文文档: http://storm.apachecn.org ApacheCN 最近组织了翻译 Storm 1.1.0 中文文档 的活动,整体 翻译进度 为 96%. 感谢大家参与到该活动中来 感谢无私奉献的 贡献者,才有了这份 Storm 1.1.0 中文文档 感谢一路有你的陪伴,我们才可以做的更好,走的更快,走的更远,我们一直在努力 ... 网页地址:

apache 优化配置详解

###=========httpd.conf begin===================##Apache主配置文件##设置服务器的基础目录,默认为Apache安装目录ServerRoot "/usr/local/apache-2.2.6"##设置服务器监听的IP和端口Listen 80##设置管理员邮件地址 ##设置服务器用于辨识自己的主机名和端口号ServerName www.uenu.com:80###设置动态加载的DSO模块##如果需要提供基于文本文件的认证,加载此模块,否

Apache Ignite——新一代数据库缓存系统

Apache Ignite是一个通用的数据库缓存系统,它不仅支持所有的底层数据库系统,比如RDBMS.NoSQL和HDFS,还支持Write-Through和Read-Through.Write-Behind Caching等可选功能. Apache Ignite是一个聚焦分布式内存计算的开源项目,它在内存中储存数据,并分布在多个节点上以提供快速数据访问.此外,可选地将数据同步到缓存层同样是一大优势.最后,可以支持任何底层数据库存储同样让 Ignite成为数据库缓存的首先.

阿里云服务器 ECS 部署lamp:centos+apache+mysql+php安装配置方法 (centos7)

1.效果图 1 2. 部署步骤 1 1. mysql安装附加(centos7) 7 3.错误注意****** 10 1.效果图 2.部署步骤 链接 http://jingyan.baidu.com/article/870c6fc31218e8b03fe4be16.html 首先安装apachecentos可以直接yum安装apache ?. 命令:yum install httpd ? //根据提示,输入Y安装即可成功安装? 然后启动apache,并且设置系统让?Apache 开机自动启动. 命

Mac OS X取消Apache(httpd)开机启动

关闭http开机启动 sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 开机启动 sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

win7 32位配置apache+wsgi+django环境

1下载xampp,里面有apache,mysql,phpmyadmin, 2 下载wsgi,http://download.csdn.net/download/copter/9192361 将对应的模块解压放到D:\programs\xampp\apache\modules 然后到D:\programs\xampp\apache\conf\httpd.conf中 # 添加mod_wsgi.so 模块LoadModule wsgi_module modules/mod_wsgi.so # Virt

通过maven test 报org.apache.ibatis.binding.BindingException: Invalid bound statement

背景 直接使用eclipse工具去执行,没有问题,通过testng.xml去执行,没有问题,但通过mvn clean test执行,就报错,提示org.apache.ibatis.binding.BindingException: Invalid bound statement 解决方法 首先先肯定的是:mybatis的配置是没有问题,因为eclipse可以正常执行: 在eclipse中把mapper的xml文件放到src代码目录下是可以一起打包进classes的,而maven去编译的时候不会,