• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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
0
St_Aug_Beach_Bum
Asked:
St_Aug_Beach_Bum
  • 2
1 Solution
 
St_Aug_Beach_BumAuthor Commented:
oh, I'm using Apache/1.3.27 (Unix)  (Red-Hat/Linux)  if that makes a difference....
0
 
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:
Cool :)

Thank you,

Chris
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now