SSL 文件夹 - 访问不安全的内容
我的网站有一个 SSL 文件夹以及一个非 SSL 部分。
如果我在 SSL 文件夹中,引用 SSL“包装器”之外的任何不安全图像,就会在 FF 中显示“您正在查看的页面的部分内容在通过 Internet 传输之前未加密”。预期的。
我通常处理这个问题的方法是在 SSL 文件夹中复制我的图像文件夹。但这可能会成为管理员的噩梦,因为我有两组图像需要更新。
是否可以使用不同的方法引用内容?也许使用 PHP 的文档根?推荐的方法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
符号链接
如果您使用的是 Linux 机器,那么您可以使用 符号链接 为整个 httpdocs 文件夹添加别名到
https
目录。这被描述为
这样,httpdocs 中的所有内容都可以通过 httpsdocs 提供给服务器,而无需复制任何内容。显然,如果您不希望符号链接全部内容,您可以仅符号链接您的图像目录。
您可以在无法更新虚拟主机容器的机器上使用此功能。
更改虚拟主机配置
这当然会导致所有对 http 和 https 的访问都从同一文档根目录访问文件。
将您的虚拟主机配置更改为:
然后创建
/etc/apache2/server-vhost.conf
,如上面两个虚拟主机配置中的Include
行所引用:Symlink
If you are on a linux box then you can use a symlink to alias all the entire httpdocs folder to the
https
directory.This is described as
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.
Change the virtual host configuration
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:
Then create
/etc/apache2/server-vhost.conf
as referenced by theInclude
lines in the two vhost configurations above:您可以使用图像的相对路径。在他的例子中,将使用与页面本身相同的协议来请求图片,HTTPS 页面使用 HTTPS,HTTP 页面使用 HTTP。
编辑:
由于我们不知道目录结构,我添加一个小例子来说明我的意思。
如果我们有一个文件
root/http/index.html
和一个图片在root/img/button.png
中,我们可以使用相对路径../ img/button.png
,无论页面位于 http 还是 https 子目录中,这都有效。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.
If we have a file
root/http/index.html
and a picture inroot/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.