George Viju
George Viju

Reputation: 423

How to show the HTTP url in Https server?

I am using application to display the Http image url in the RSS. But while loading this image in the HTTPS server and opening in Internet Explorer showing Security warning. How to solve this problem? How this can be handled using java and display in RSS?

Upvotes: 0

Views: 1333

Answers (3)

Bruno
Bruno

Reputation: 122649

If the image (or other content) is hosted on the same host, the simplest is to use a relative-path reference or an absolute-path reference (i.e. src="path/to/image.png" or src="/path/to/image.png).

If the image is on a different host that serves the same content over HTTPS (with a certificate likely to be trusted by your users too) and plain HTTP (at least for this resource), use a network-path (relative) reference, i.e. omit the scheme from the URI (e.g. src="//the.host.name/path/to/image.png").

If that other host doesn't serve this content over HTTPS, this becomes more complex. One work-around is to serve it yourself via a reverse-proxy which would query this content. The address used by the client would point to your HTTPS server, and your server would fetch the content in the back. You may want to consider the following points when doing this:

  • Security: you're effectively serving someone else's content via your host, but should it be trusted as coming from your host? Perhaps this should be a separate HTTPS host than your main HTTPS site.
  • Bandwidth: all the content is going to be served by your host effectively, and you may have to fetch it first.
  • Legal: this may or may not be considered as hosting someone else's content.

Upvotes: 0

Matt Ball
Matt Ball

Reputation: 359816

Use scheme-relative URLs. That mean URLs that look like this:

<img src="//example.com/images/foo.jpg"/>

instead of this:

<img src="http://example.com/images/foo.jpg"/>

More reading: Is it valid to replace http:// with // in a <script src="http://...">?

Upvotes: 1

David B&#233;langer
David B&#233;langer

Reputation: 7438

I don't know Java, but you could do :

var STRING

IF SSL DETECTED
   STRING = REPLACE HTTP WITH HTTPS

ECHO STRING

Do this inside the loop.

The best way to do it is to create two main constant with both url in http and https and use thoses as prefix in your url whatever SSL is detected or not.

Upvotes: 0

Related Questions