通过httpd.conf将http重定向到https [英] redirect http to https through httpd.conf
本文介绍了通过httpd.conf将http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要将http更改为https.
http://myServerName/itf/sheldon/imex/ajax/share_details/v1/CH0012221716/issuer/contact.json **Should change to** https://myServerName//itf/sheldon/imex/ajax/share_details/v1/CH0012221716/issuer/contact.json
为此,我在 httpd.conf 文件
*LoadModule rewrite_module modules/mod_rewrite.so
RewriteCond %{HTTPS} off
RewriteEngine On
RewriteRule ^(.*)(\/itf)(\/sheldon\/)(.*)\.(json|JSON)$ https://myServerName/$2$3$4.json [L,R=301,NC]
RewriteRule "^(.*)(\/itf)(\/fqs\/)(.*)\.(json|JSON)(.*)$" https://myServerName/itf/fqs/$4.json$6 [R=301,L,NC]
Include conf/vhost.conf*
The vhost.conf file have necessary configuration for virtualhost:443
So I am able to get the result if I use https://myServerName/....,
**but not able to get the result with** http://myServerName/...
推荐答案
设置您的虚拟主机文件/httpd.conf以包含行
Set up your virtual host file / httpd.conf to have lines
<VirtualHost *:80>
ServerName enter.yoursite.com
Redirect / https://enter.yoursite.com/
</VirtualHost>
<VirtualHost *:443>
ServerName enter.yoursite.com
ServerAdmin some@email.com
Insert EVERYTHING else in here (rewrite rules, log file stuff, etc)
</VirtualHost>
这将强制网站始终重定向到HTTPS,然后在HTTPS下加载所需的所有配置.
This will force the website to always redirect to HTTPS and then load all the configurations you want under HTTPS.
这篇关于通过httpd.conf将http重定向到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文