我在我的网站中强制使用 ssl:
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
但我使用的是没有启用 SSL 的广告 newtork。是否可以在不向用户发出不安全内容警报的情况下替换该内容?也许有一个例外?
I don't believe you'll have any luck with that. The ad network needs to provide SSL
code. The browser/client tells you that you are displaying insecure content and htaccess won't be able to hide that.
Even Google Adsense does not have SSL
support. Internet explorer is typically the browser that gives the intrusive dialog warning versus other browsers show the error in the console. There are ad networks that do offer SSL though.
In Chrome, if the https
connection is broken it shows it in the address bar crossed out in red. I personally don't want users to see that and think my site is not secure in certain areas just because of some ads.
I don't encrypt my whole site because I don't feel it's necessary. It seems to be a fad these days but I feel it's overkill and unnecessary most of the time. I only use SSL
on important pages such as login pages, account settings or any type of payment area. Otherwise the whole site doesn't need it and will prevent users from seeing the insecure content warning. If you're whole site is not one big site of sensitive content and probably isn't sense it most likely public, maybe it's not necessary to force https
on your entire site. Just a suggestion to get around the warning message.
Updated:
Try this code in regards to your comment.
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} (signup|settings)
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]