Apache配置http访问转https(widows和linux通用)
2017-05-10 18:10
766 查看
默认情况下,apache的80端口网站目录是/var/www/html
查找配置文件并修改/etc/httpd/conf/httpd.conf
利用伪静态功能
<Directory "/var/www/html">
#
# 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 Indexes 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
</Directory>
然后在需要跳转的网站根目录,也就是80端口的网站根目录/var/www/html下创建一个.htaccess文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
保存,重启httpd服务,再次访问http://域名,发现会直接跳转到https://域名
配置成功。
扩展阅读和参考资料
http://blog.csdn.net/luhuisicnu/article/details/50402822
查找配置文件并修改/etc/httpd/conf/httpd.conf
利用伪静态功能
<Directory "/var/www/html">
#
# 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 Indexes 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
</Directory>
然后在需要跳转的网站根目录,也就是80端口的网站根目录/var/www/html下创建一个.htaccess文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
保存,重启httpd服务,再次访问http://域名,发现会直接跳转到https://域名
配置成功。
扩展阅读和参考资料
http://blog.csdn.net/luhuisicnu/article/details/50402822
相关文章推荐
- Apache配置http访问转https
- Linux下SVN服务器同时支持Apache的http和https及svnserve独立服务器三种模式且使用相同的访问权限账号
- Apache mod_proxy通过https访问后端服务器的配置
- 在Linux(Fedora 16)上配置Tomcat 7.0.x 和Apache Http Server 2.2.x 集成
- Centos6.3下Apache配置https证书访问
- Linux下ssl+http 实现 HTTPS 访问服务器设置
- web.xml中配置http访问转向https
- 利用 mod_jk 整合 Apache HTTP Server 与 Tomcat 配置(linux)
- Ubuntu 配置Apache访问linux目录
- Tomcat配置https及访问http自动跳转至https
- 在Linux上配置Apache HTTPS服务
- Apache搭建反向代理用Http访问Https站点
- 通用http、https访问工具类
- ubuntu12.04安装subversion并配置nginx+apache通过http方式访问
- linux系统下用单向认证方式将Tomcat配置成https方式访问
- Linux apache配置https
- SVN-1.5.3+Apache-2.0.59在windows下的配置与权限设置,以及配置HTTP方式访问SVN服务器
- 让apache服务器可以保证http和https同时访问(解决https可以访问而http不能访问)
- Apache http强制转为https页面访问(转)