通过httpd.conf将http重定向到https

2023-12-12

需要把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 file

*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 中包含以下行

<VirtualHost *:80>
  ServerName enter.yoursite.com
  Redirect / https://enter.yoursite.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName enter.yoursite.com
  ServerAdmin [email protected]
  Insert EVERYTHING else in here (rewrite rules, log file stuff, etc)
</VirtualHost>

这将强制网站始终重定向到 HTTPS,然后在 HTTPS 下加载您想要的所有配置。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过httpd.conf将http重定向到https 的相关文章

随机推荐