当前位置: 动力学知识库 > 问答 > 编程问答 >

.htaccess - http to https force redirect excluding addon websites

问题描述:

My primary domain stands on a cpanel account. Let's call it "myprimary". In that domain I've installed an SSL. By default the SSL it is only accessible only if you force url to redirect any http request to an https url.

For this reason I used the following code (inside .htaccess) which works pretty good.

RewriteEngine on

RewriteCond %{HTTPS} !=on

RewriteCond %{HTTP_HOST} ^myprimary.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.myprimary.com$

RewriteRule .* https://www.myprimary.com%{REQUEST_URI} [R=301,L]

Header set Content-Security-Policy: upgrade-insecure-requests

ALso I've added an addon domain which appears as (you already know) as a folder in the public_html (which is the root for my primary one). The addon website has no SSL installed there.

Using the code above it forces the browser to ask for https even in the addon causing it to fail and not to load at all. So is there any way to have a redirect to https for the primary and exclude the website inside (I guess the directory).

Thank you all in advance.

分享给朋友:
您可能感兴趣的文章:
随机阅读: