Can I use htaccess to change http to https in image tags when needed?

I purchased a php script I'm using on a site.

I want to secure some of the pages (https).... however, in this rather complex script, all the images are absolute and point to http://www...  which causes a security warning saying parts of the page aren't secure.

Is there a way that I can use htaccess to change any reference to 'background="http://www.'  and 'img src="http://www.'   on the page to their https equivilents before the page is sent to the user?

If not, any other thoughts on this, other than rewriting the whole php script?

Thanks,

Chris
St_Aug_Beach_BumAsked:
Who is Participating?
 
hernst42Commented:
See http://www.php.net/manual/en/ref.outcontrol.php

start the output-buffer with at the beginning of the https-page:

<?php ob_start('makehttps'); ?>


function makehttps($text) {
   $text = str_replace('background="http://www.', 'background="https://www.', $text);
 ...
   return $text;
}

Rest will be done by php.
0
 
St_Aug_Beach_BumAuthor Commented:
oh, I'm using Apache/1.3.27 (Unix)  (Red-Hat/Linux)  if that makes a difference....
0
 
St_Aug_Beach_BumAuthor Commented:
Cool :)

Thank you,

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.