Preface
A search on the Internet, the same thing, is to set a certain directory to force access to https, which is just the opposite of my needs.
demand
I need to set mandatory https access for the main site, but a separate directory still uses http access.
In this way, you can set a second-level domain name for a separate directory , otherwise the browser will still access the https site in the sub-directory by default , but without the certificate file of the second-level domain name , it will cause access errors .
achieve
Create a new .htaccess in the home directory of the website and fill in the following content to set mandatory https access for the main website
#强制https
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
The above is all nonsense . The following is the best configuration.
Let a certain subdirectory not access https.
Create a new .htaccess in the subdirectory and fill in, RewriteEngine Off
save and close.