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
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
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
Share on other sites

I must use a relative path for my CSS and Javascript files. The relative path works fine when I go to my store's folder (not the subdomain); however, when I navigate to the subdomain itself, the CSS style sheet is not loading. Does anyone know what this could be?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.