Apache 通过httpd.conf将http重定向到https
需要将http更改为https。Apache 通过httpd.conf将http重定向到https,apache,mod-rewrite,httpd.conf,Apache,Mod Rewrite,Httpd.conf,需要将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文件中有以下
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设置为具有行
<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>
ServerName enter.yoursite.com
重定向/https://enter.yoursite.com/
ServerName enter.yoursite.com
服务器管理员some@email.com
在此处插入所有其他内容(重写规则、日志文件等)
这将迫使网站始终重定向到HTTPS,然后在HTTPS下加载您想要的所有配置。我找到了解决方案:
要将特定或任何http调用更改为https调用,请将代码放入
VirtualHost :80
ErrorLog /var/log/httpd/error_log
CustomLog logs/access.log common
LogLevel info
RewriteCond %{HTTPS} off
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
RewriteEngine On