Forum Moderators: phranque

Message Too Old, No Replies

ssl warning contains unauthenticated content

CSS and JS links is not being read as https in https pages

         

aramtch

8:26 pm on Jan 7, 2011 (gmt 0)

10+ Year Member



Hey guys... I've got a site running on Wordpress. All of the images in the content are referenced by the entire url (http://www.domain.com/images/image.jpg). The problem is, when trying to hit the site using "https", users obviously get the SSL Warning message about the page containing unauthenticated content.

I could change them ALL to https, but that would entail going through like 100 pages and changing all of them.

Is there anything I can do it .htaccess that will rewrite the references to any images (or in some cases, css files, also) to "https"?

Or is that impossible?

thanks in advance...

jdMorgan

1:26 pm on Jan 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If a given page is always SSL/HTTPS or if it is always non-SSL/HTTP, you can use page-relative, root-relative, or canonical linking on that page.

If a page can be accessed using either HTTPS or HTTP, then use only page-relative or root-relative linking on that page, unless you are generating the page dynamically with a script can dynamically determine the proper protocol to specify in canonical links.

Examples of my terminology:

Page-relative links: <img src="logo.gif"> or <img src="../logo.gif"> or <img src="../images/logo.gif">

Root-relative link: <img src="/images/logo.gif">

Canonical link: <img src="https://example.com/images/logo.gif"> or <img src="http://example.com/images/logo.gif">


It is the client (e.g. a browser or search engine robot) which resolves links on your page to the canonical form it needs to send a HTTP or HTTPS request.

If a page-relative link is specified on a page, the browser strips off the part of the URL following the last slash in its address bar (i.e. it removes the "page name"), appends the specified page-relative link, and issues a request for the resulting canonical URL.

If a root-relative link is specified on a page, the browser strips off the part of the URL following the first single slash in its address bar (i.e. it removes everything after the "domain name" and the optional port number), appends the specified root-relative link, and issues a request for the resulting canonical URL.

If a canonical link is specified on a page, the browser simply uses it as specified.

Note that only the canonical-link format can or will change the protocol.

Jim

aramtch

2:33 pm on Jan 9, 2011 (gmt 0)

10+ Year Member



OK thanks for the clarification. My question then would be, is there a way I can use .htaccess to rewrite all cononical links src links (ie. src="http://www.website.com/image.jpg", src="http://www.website.com/script.js", src="http://www.website.com/main.css") to "https"? Or impossible.

All the images in the content of all of our pages are referenced with canonical links, and i'm trying to avoid going through every single page and changing them all to page-relative.

jdMorgan

3:20 pm on Jan 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



.htaccess rewrites *requests*, not links.

Requests arrive at your server *after* someone clicks a link.

Therefore, you will have to edit your pages to change the links.

There are many good multi-file "find and replace" tools available on-line, many of which are free. Many HTML editors (some free as well) also include this function. Using the right tool with the right filename-selector and link-selectors, it takes only seconds to edit one or more links on 100 pages...

Jim

aramtch

7:10 pm on Jan 9, 2011 (gmt 0)

10+ Year Member



awesome - thanks for your help jd!