如何允许访问域的流量转到 https,子域除外

how to allow traffic to domain to go to https except subdomains

我有一个网站可以将所有流量引导至我网站的 https 版本。 以下代码允许在 .htaccess 文件中发生这种情况。我如何修改它以允许访问我的子域,因为我的子域被下面的代码阻止了?

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

它应用于此网站http://www.asisa.org/. I need access to http://stage.access.org.za/,但上面的代码阻止了它。

您只需添加一个条件来声明重定向只应发生在主域上,无论是否使用 www.。在规则上方添加以下内容:

RewriteCond %{HTTP_HOST} ^(www\.)?asisa\.org\.za$ [NC]

这将确保任何子域,例如 http://stage.asisa.org.za/ 在访问时不会强制使用 HTTPS。

Note: You seem to have conflicted between asisa.org and asisa.org.za - I have used the latter as the site appears to be for a South African organisation.