简体   繁体   English

在我的WordPress网站上强制使用https…(特定子域除外)

[英]Force https for my WordPress site…except for a specific sub-domain

I'm trying to figure out how I can exclude one specific sub-domain of my WordPress site from being forced to HTTPS. 我试图弄清楚如何才能将我的WordPress网站的一个特定子域排除在强制使用HTTPS之外。

Here is my .htaccess: 这是我的.htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # HTTPS by default
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>

This code perfectly works to enforce HTTPS. 此代码完美地执行了HTTPS。 Now, I want my download.domain.com to stay in plain HTTP, not encrypted. 现在,我希望我的download.domain.com使用纯HTTP,而不是加密的。 I've tried many many things, and I didn't manage to get something which works. 我尝试了很多事情,但没有设法得到可行的解决方案。

Thanks. 谢谢。

# HTTPS by default except for download.domain.com
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !=download.domain.com
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This should do the trick. 这应该可以解决问题。

When you are testing, be aware that browsers cache 301 redirects - so you might reject working solutions because your browser fools you. 在测试时,请注意浏览器会缓存301重定向-因此您可能会拒绝有效的解决方案,因为您的浏览器会欺骗您。 Make sure to open browser dev tools and disable request cache. 确保打开浏览器开发工具并禁用请求缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM