我发现了很多这样的问题并尝试了几乎所有但失败了。我最新的代码是:
RewriteCond %{HTTPS} !^on$
RewriteCond %{REQUEST_URI} (/page_1|/page_2|/page_3|/page_3)$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
我只想将这些页面的 http 重定向到 https (page_1 - page_4)
最初它似乎是有效的,但是一旦我使用https到达 page_1 并单击不应该是https的任何其他(比如说page_my_http_1 )链接,它也会重定向到该页面的 https (page_my_http_1)。
我也试过:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (auth|register|secure)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(auth|register|secure)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]
或者如果 SSL 证书未在浏览器上激活,有什么方法可以向用户显示自定义消息?
实际上,当浏览器显示默认警告消息时,许多非技术用户都会感到震惊。