Jump to content

File paths and SSL


mjurmann

Recommended Posts

Hello, for some reason when going to my secure server, https:///www.site.com, I get an error telling me that the information on the page is partially encrypted. After researching this matter a bit, I discovered that I am getting this error because the file paths on my https: and http: sites are both absolute and all files within begin with http://. Therefore, the https: is telling me that the information is partially encrypted because there are http:// file paths inside of the https:// site.

 

Does anyone know of a way to fix this? Can I just have all of the absolute http:// file paths be rewritten to https://, or will that bog down resources? Is there any better way of doing this?

 

It seems to be a big problem, with hopefully a simple solution.

 

Thank you to anyone who can help me.

Link to comment
https://forums.phpfreaks.com/topic/99238-file-paths-and-ssl/
Share on other sites

Relative links are your best bet, otherwise, use object buffering and do this

 

<?php

ob_start();

// do code ect

$subject = ob_get_clean();

if ( strstr($_SERVER['SERVER_PROTOCOL'], 'HTTPS') )
    $subject = str_replace('http', 'https', $subject);

echo $subject;

?>

 

Or you can use preg_replace to replace with stricter rules

Link to comment
https://forums.phpfreaks.com/topic/99238-file-paths-and-ssl/#findComment-507869
Share on other sites

I'm trying to use relative links, and to my surprise this isn't working.

 

The original CSS file is at: http://www.site.com/css/styles.css

 

So in the <HEAD>, I have:

 

<link href="http://www.site.com/css/styles.css" rel="stylesheet" type="text/css" media="screen" />

 

This works fine. However, when I try to use a relative path, it doesn't work.

 

<link href="../css/styles.css" rel="stylesheet" type="text/css" media="screen" />

 

I have a ../css because the styles.css file is being called from http://www.site.com/includes/stylesheet-caller.php.

 

I've been working with PHP for a while now, and can't believe this is happening. Why would the CSS file not be included? The css directory is in the same root as the includes/ directory, so shouldn't it be: ../styles.css

 

What the heck is going on here?

Link to comment
https://forums.phpfreaks.com/topic/99238-file-paths-and-ssl/#findComment-507924
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.