tags:

views:

29

answers:

2

Hello,
Ok here's my issue I have a file that is delivered through https, all the files on my server have a common header.php file that is included within files. In the header file i have all my stylesheets etc called from my cdn folder. http://cdn.domain.com since they are called http in my https file (via header.php) it doesnt transmit fully in https.

Is there a way to have htaccess make all transactions on a https page via https even if it is trying to get the http version ? Or is my best bet to coding it in the PHP?

Thanks

A: 

Just remove http: from all your URL's. It will use http or https depending on what protocol the webpage is using.

Lekensteyn
Yea but here's the issue since the css/js and stuff are on a different subdomain (cdn.domain.com) if i remove http:// and just leave cdn.domain.com/css/css.css its makes it seems like a relative path.
William Smith
I may just have to stick to doing it in PHP<?php $protocol = (!empty($_SERVER['HTTPS'])) ? "https://" : "http://"; ?>
William Smith
+1  A: 

This isn't really a server configuration issue. What you need to do is ensure that the server is returning "https" for the location of all of your external resources (css, javascript & images).

Your best bet with a common header file is to use relative urls (no http(s)://example.com/) and let the browser determine the protocol that should be used.

If the css et al are on a different domain, then I'd just detect the protocol being used and massage the protocol in your html before returning it to the user.

Or you can just use HTTPS everywhere ;0)

hafichuk
Lol yea i figured thats what it would come down too thanks.Used this<?php $protocol = (!empty($_SERVER['HTTPS'])) ? "https://" : "http://"; ?>
William Smith