Forum Moderators: phranque
http://example.com -> http://www.example.com
However I have found a problem with the CSS backgrounds. If I don't ignore the directory containing the CSS ("includefiles" below), when it goes to https it gives a "partially encrypted" warning. Viewing page info in FF reveals the images being called by the CSS are not secure.
I think I may have solved it, but would prefer not to take chances. Does this look right?
images are in /images
.css and .js are in /includefiles
Example:
.some_selector { background: url(/images/bg.gif) top left repeat-x; }
My rewrite rules, of course this board removes the spaces before the exclamation points:
RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.example\.com
# For included files, JS and CSS
RewriteCond %{REQUEST_URI}!\/includefiles\/
RewriteCond %{REQUEST_URI}!\/images\/
RewriteCond %{HTTPS}!^443$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} (www\.)?example\.net [OR]
RewriteCond %{HTTP_HOST} (www\.)?example\.org
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
If I comment out the bolded lines, I get the partially encrypted warning. ("So don't do that Bill.") Just concerned it may break something else.
If your http and https filespaces are separate, a 'tricky' method you can use to avoid problems of resources shared between http and https is to create 'fake' image and script directories in the https filespace, and symlink these to the 'real' ones in the http filespace.
Jim
src="/images/filename.jpg"
Same for .js and css. What it was doing was placing the non-secure version of, say, background images:
<link rel="/include_files/my.css">
<div style="some-style">
.some-style { background:url(/images/bg.jpg); }
So it should have gone from domain root in any case, secure or not, but doesn't until I added the include_files and images directory in the rules.
It seems very odd (well -- very wrong, actually) that the browser would improperly resolve a server-relative link in https to http://domain/link instead of retaining both the protocol and the domain. If this is the case with all browsers, then the only way to avoid the exclusion requirement would be to use canonical image and script links -- and that is, as I like to say, "non-optimal."
Jim
This is why I suggested a review of the site -- The most likely cause is that the SSL pages are being allowed to be requested from the 'wrong' domain, and therefore the links from those pages are getting redirected and breaking the http/https distinction.
Jim
Other than that, all images, include files, etc. are requested by /, I don't use ../ or full links except for the precise links from the secure pages BACK to non-secure links, i.e.
http://www.example.com/contact.html
The rest of my .htaccess is as follows, you know what it's doing:
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ /cgi-bin/cart-script.cgi [L]
Cart-script doesn't do any special loops or rolls to the images or CSS links - these are contained in a page template, using the same syntax (/include_files/myfile.css)
Thanks again, frankly I don't know where else to look.
Domain root is /site.com/some-directory (like html, whatever)
CGI executables are only allowed in /site.com/cgi-bin
The only place I've seen this is in the cgi scripts. Possibly this is the issue? The .htaccess above is only located in the domain root.