How to convert http to https using apache. Please give me more details. Thank you.
phpcn_u74895
phpcn_u74895 2017-12-12 21:09:10
0
3
1804

The apache server I want to use to convert http to https

I downloaded Alibaba Cloud’s free ssl certificate. How to configure it

Please be more detailed. Thank you

phpcn_u74895
phpcn_u74895

reply all(1)
broadsword

How to set http to automatically jump to https? In the apache environment, after configuring https, you need to set url redirection rules so that http access to website pages will automatically redirect to https access.

1. First enable url redirection support
1) Open Apache/conf/httpd.conf, find #LoadModule rewrite_module modules/mod_rewrite.so and remove the # sign.
2) Find the <Directory> section of your website directory. For example, my website directory is c:/www, find
<Directory “C:/www”>

&lt ;/Directory>
Modify AllowOverride None to AllowOverride All3) Restart the apache service 2. Set redirection rules
1) Place an .htaccess file in your website directory. In the Windows environment, you cannot directly rename the file to .htaccess. You will be prompted to enter the file name. So we first create a new "New Text Document.txt" document, open Notepad, select Save As, select "All Files (*.*)" as the save type, enter ".htaccess" as the file name, and save. This generates a .htaccess file.

2) Open the .htaccess file in the editor and write the following rules:
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI } !^/tz.php
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]

Explanation:
%{SERVER_PORT} —— Access port
%{REQUEST_URI} - For example, if the url is http://localhost/tz.php, it refers to /tz.php
%{SERVER_NAME} - For example, if the url is http://localhost/tz.php, It refers to localhost

The above rules mean that if the port of the accessed url is not 443 and the accessed page is not tz.php, the RewriteRule rule will be applied. This is achieved: when accessing pages such as http://localhost/index.php or http://localhost/admin/index.php, it will automatically jump to https://localhost/index.php or https:/ /localhost/admin/index.php, but no jump will be made when accessing http://localhost/tz.php, that is, http://localhost/tz.php and https://localhost/tz .php is accessible from both addresses.


  • reply I tried your method but it didn’t work. Apache couldn’t start.
    王亮 author 2017-12-16 18:19:46
  • reply Same
    小叮当 author 2018-03-19 17:03:13
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template