1

I have a url that is used to store data across multiple sites based on client ID. Many of our clients are now wanting to use secure https resolution, yet the data referenced on their sites from this specific url is not currently secure, therefore I'm getting an error that "some parts of this page are not secure (such as images)", and I'm looking for a rewrite condition that would enable forwarding of the storage location url to https if it's being referenced from an https site only, yet still allows http resolution of the same storage url if not.

Any assistance on this topic would be greatly appreciated. Thanks in advance to all contributors. David W.

  • If the only thing changing on the url is http vs https, I think all the current browsers now support references like <img src="//cdn.example.com/path/to/file" /> where the protocol to use is assumed to be the protocol of the main page. – ivanivan Jun 22 '18 at 1:51
0

Put this in your Apache config

RewriteCond %{HTTP_REFERER} ^https://
RewriteCond %{HTTPS} !=on # This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.