Reputation: 812
I have an SSL folder as well as a non SSL part to my site.
If I'm in my SSL folder, referencing any insecure images outside the SSL 'wrapper' gives me the "Parts of the page you are viewing were not encrypted before being transmitted over the Internet" in FF. Expected.
The way I would usually deal with this issue, is to make a copy of my images folder within the SSL folder. But that could turn out to be an admin nightmare becuase I have two sets of images to update.
Is it possible to reference content by using a different method? Perhaps using PHP's document root? What is the recommended method?
Upvotes: 1
Views: 823
Reputation: 21553
If you are on a linux box then you can use a symlink to alias all the entire httpdocs folder to the https
directory.
ln -s /var/www/vhosts/example.org/httpdoc /var/www/vhosts/example.org/httpsdoc
This is described as
ln -s source_file link_name
This way everything that is in httpdocs is available to the server via httpsdocs as well without copying anything. Obviously if you do not wish to symlink the whole lot you could just symlink your images directory.
You can use this on a box where you are unable to update the virtual host container.
This will of course cause all access to both http and https to access the files from the same document root directory.
Change you vhost configuration to be:
# Virtual Hosting
<VirtualHost *:80>
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
Include /etc/apache2/server-vhost.conf
</VirtualHost>
# SSL Virtual Hosting
<VirtualHost *:443>
<IfModule mod_ssl.c>
SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
</IfModule>
Include /etc/apache2/server-vhost.conf
</VirtualHost>
Then create /etc/apache2/server-vhost.conf
as referenced by the Include
lines in the two vhost configurations above:
ServerName example.org
ServerAdmin [email protected]
DocumentRoot /var/www/vhosts/example.org/httpdoc
Upvotes: 1
Reputation: 24101
You could use relative path's to your images. In his case the pictures will be requested with the same protocol as the page itself, HTTPS for a HTTPS-page and HTTP for a HTTP-page.
Edit:
Since we don't know about the directory structure, i add a small example of what i mean.
root/http/index.html
root/https/index.html
root/img/button.png
If we have a file root/http/index.html
and a picture in root/img/button.png
, we can use the relative path ../img/button.png
, this will work whether the page is in the http or in the https subdirectory.
Upvotes: 0