Forum Discussion

Dave_21507's avatar
Dave_21507
Icon for Nimbostratus rankNimbostratus
Aug 14, 2008

redirect uri to https

Hello,

 

 

We have a .NET application hosted in IIS that has a bunch of static links to image files in http://host/images/file.jpg . What I'm looking to do is redirect (or rewrite?) img links on the pages from http://host/images/file.jpg to https://host/images/file.jpg - the purpose is so that IE users don't get the warning that some items are secure and others not.

 

 

Here's what I have so far:

 

 

 

when HTTP_REQUEST {

 

if { ( [HTTP::uri] starts_with "/images" ) }{

 

HTTP::redirect https://[HTTP::host][HTTP::uri]}

 

}

 

 

Any ideas? It isn't working as planned.

 

 

I also tried this approach (to no avail):

 

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri]] {

 

"*images/" {

 

HTTP::respond 301 Location "https://[getfield [HTTP::host] : 1][HTTP::uri]"

 

}

 

}

 

}

 

 

Am I going in the right direction or should I take the approach of rewriting img links?

 

 

Thanks!

3 Replies

  • There is a stream profile that you can use to rewire links in static pages

     

    Click here to view.

     

     

    I hope this helps,

     

    CB

     

  • You need to rewrite the links in the page before they are requested by the browser (using the stream profile, as mentioned). If you wait until the objects are requested (as you were trying to do) it is too late to rewrite them to avoid the error.
  • Okay great, thanks for the tips guys! I will see if I can create a Stream profile to handle it.