美文网首页
Apache2.4配置http自动跳转到https

Apache2.4配置http自动跳转到https

作者: 洛阳醉长安行 | 来源:发表于2019-01-11 19:49 被阅读0次

部署完成的php项目想要http自动跳转到https,前提是需要能够https访问到php页面,如何配置https需要获得相关证书文件(key,crt) ,然后需要在httpd.conf和httpd-ssl.conf中修改相关配置,更多的不在赘述。以下内容建立在https能独立访问自己的页面成功后才能实行。

首先在httpd.conf中配置如下:
打开Apache重写模块(把#号去掉):

LoadModule rewrite_module modules/mod_rewrite.so  

然后修改Directory里的内容,注意是修改标签包含自己项目路径的配置项

DocumentRoot "E:/wsp/www"
<Directory "E:/wsp/www">
 Options Indexes FollowSymLinks
AllowOverride All
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Require all granted
</Directory>

在bin目录中打开cmd运行 httpd -t 如果语法没错就重启Apache就成功了

相关文章

网友评论

      本文标题:Apache2.4配置http自动跳转到https

      本文链接:https://www.haomeiwen.com/subject/qkhfdqtx.html