php - 从 http 切换到 https 在不同的浏览器上会出现不同的错误?

标签 php .htaccess browser https ssl-certificate

我想在 https 上运行几个页面,而所有其他页面在 http

上运行

我在 .htaccessconfig.inc.php 文件中写了下面的代码

.htaccess

RewriteEngine on
Options +FollowSymLinks 
RewriteBase /

RewriteRule ^login/?$ login.php [NC]

# Rewrite non www to www.charityrummage.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Rewrite to https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /login [OR]
RewriteCond %{REQUEST_URI} /do_login.php [OR]
RewriteCond %{REQUEST_URI} /payment/?.*$ 
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

# traffic to http://, except login.php and payment.php
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(/login|/do_login.php|/payment)
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

还对 config.inc.php 进行了一些更改,这是网站的第一个必需文件

config.inc.php

$ssl_page = array('login.php','do_login.php','payment.php');
// Note: do_login.php is intermediate page
if(in_array(trim($_SERVER['SCRIPT_NAME'],'/'),$ssl_page)){
    define('PROTOCOL','https://');    
 }else{
   define('PROTOCOL','http://');
}
define('DS','/');
define('URL',PROTOCOL.$_SERVER['HTTP_HOST'].DS);
// based on URL i made CSS and JS Path

这是网站链接:

http://www.charityrummage.com.

登录页面启用了 ssl :

https://www.charityrummage.com/login

但是

当我运行该网站时,它会在不同的浏览器上给出不同的错误,这真的很烦人。下面是在不同浏览器上的错误描述

IE8

it always prompt for security error and
if i click on Yes then display everything fine except left panel
if i click on NO then certificate error near web address but website works fine.

Chrome (v:20.0.1132.8)

display multiple warning about css and js ( see in console ) in below format:

The page at https://www.charityrummage.com/login ran insecure content from http://www.charityrummage.com/css/reset.css

but if you view source of login page then you can see that every css and js running with https://

火狐(16.0 版)

it display lock sign ( secure ) just for few seconds and then gone away
( i m surprised it never prompt security alert for https ) but when we go with page info -> media then many of images are coming from http://

请检查并告诉我确切的问题是什么好吗?

我还想知道一件事。

if https:// pages are not displaying properly then which one is responsible

  • 操作系统或
  • 浏览器或
  • 服务器或
  • 编程问题或
  • SSL证书问题

    最后这个问题的解决方案是什么?

谢谢

最佳答案

试试这个规则:

# Force files ending in X to use same protocol as initial request
RewriteRule \.(gif|jpe?g|png|ico|css|js)$ - [S=1]

或者这个:

# don't do anything for images/css/js (leave protocol as is)
RewriteRule \.(gif|jpe?g|png|ico|css|js)$ - [NC,L]

# 流量到 http:// 之前

关于php - 从 http 切换到 https 在不同的浏览器上会出现不同的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12317079/

相关文章:

android - 让所有浏览器都支持我的背景图片?

javascript - ajax更新后无法使用jquery选择表行id

PHP 扩展 : How to return a new class object

php - 如何显示不同或所有类别的内容?

.htaccess - htaccess,为每个域添加规则

apache - 只允许美国用户访问网站

android - android布局中的WebBrowser控件

php - MySQL创建的线程快速增长

php - Symfony - app_dev.php 中的 ClassNotFoundException

javascript - window.location 可以进行哪些 XSS 攻击