Apache 使用htaccess规则在子域上进行不需要的https重定向

Apache 使用htaccess规则在子域上进行不需要的https重定向,apache,.htaccess,mod-rewrite,ssl,Apache,.htaccess,Mod Rewrite,Ssl,我有一些子域s1.mywebsite.com和s2.mywebsite.com。我正在尝试设置一个URL重写规则,以便将任何针对mywebsite.com的请求转换为https,而对子域的请求不会改变 现在,在我的主域的根目录中,我有一个htaccess文件,其中包含以下内容: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule .* https://mywebsite.com/%{REQUEST_URI} [

我有一些子域
s1.mywebsite.com
s2.mywebsite.com
。我正在尝试设置一个URL重写规则,以便将任何针对mywebsite.com的请求转换为https,而对子域的请求不会改变

现在,在我的主域的根目录中,我有一个htaccess文件,其中包含以下内容:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule .* https://mywebsite.com/%{REQUEST_URI} [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

那里有一些wordpress的内容。目前,我的服务器重写了请求
http://s1.mywebsite.com/page/
https://mywebsite.com/page/
完全删除子域。如何让我的规则忽略子域查询?

添加一个条件以限制仅主域的第一个
https->http
规则:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(?:www\.)?mywebsite\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

完美的非常感谢!