redirect http to https through httpd.conf

三世轮回 提交于 2019-12-02 04:42:26

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>

This will force the website to always redirect to HTTPS and then load all the configurations you want under HTTPS.

I found the solution: To change particular or any http call to https call, put the code in

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!