Apache server enables HTTPS access
PHP中文网
PHP中文网 2017-05-16 17:01:15
0
2
685

Currently, Apache is installed on a Centos, and three virtual machines are created, one of which is configured with an SSL service. The effect I want is to disable HTTP access and only allow HTTPS access. How to configure and implement this?

Current situation: Both HTTP and HTTPS can be accessed.

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
过去多啦不再A梦

Do you want to force http to jump to https access, or do you want http to be directly set to be inaccessible? Generally, websites that deploy https will take into account that users are accustomed to http input, and will configure the server to force http to jump to https. The Apache server configuration is as follows:
If you need to jump to the entire site, then in the <Directory> tag of the website's configuration file , type the following:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/ [L,R]

If you want to force https redirect to a certain directory, copy the following code:

RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/ [L,R]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
習慣沉默

Just delete the virtual host corresponding to the http you configured.
https is a virtual host configured with ssl, so the original http configuration has no impact on it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template