Https://www.cnblogs.com/niejunlei/p/5279677.html
How do I set HTTP to automatically jump to HTTPS?
Apache environment, after configuring HTTPS, you need to set the URL redirection rules, so that the Site page HTTP access to automatically go to HTTPS access.
1, first open URL redirection support 1) Open apache/conf/httpd.conf, find #LoadModule rewrite_module modules/mod_rewrite.so Remove the # number. 2) Find the <Directory> section of your site directory, such as my Site Directory is c:/www, find
<directory "C:/www" >
...
</Directory>
Modify the allowoverride None to allowoverride all 3) Restart Apache Service 2, set redirection rules
1) A. htaccess file is placed on your site directory. In a Windows environment, you cannot rename a file directly to. htaccess, and you will be prompted to enter a file name. So let's start with a new "new text document. txt" document, open Notepad, select Save As, type select "All Files (*. *)", file name ". htaccess", save. This generates a. htaccess file.
2) The editor opens the. htaccess file and writes the following rules:
Rewriteengine on
Rewritecond%{server_port}!^443$
Rewritecond%{request_uri}!^/tz.php
Rewriterule (. *) https://%{server_name}/$1 [R]
Explain:
%{server_port}--Access Port
%{request_uri}--For example, if the URL is http://localhost/tz.php, it means/tz.php
%{server_name}--For example, if the URL is http://localhost/tz.php, it means localhost.
The above rule means that if the port of the URL being accessed is not 443 and the access page is not tz.php, then the rule is applied rewriterule. This is achieved: access to the http://localhost/index.php or http://localhost/admin/index.php and other pages will automatically jump to https://localhost/index.php or https://localhost/admin/index.php, but when you visit http://localhost/tz.php, you don't make any jumps, which means http://localhost/tz.php and https:/ /localhost/tz.php two addresses can be accessed.
Apache how to set HTTP to automatically jump to HTTPS