我想在 https
上运行几个页面,而所有其他页面在 http
我在 .htaccess 和 config.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
这是网站链接:
登录页面启用了 ssl :
但是
当我运行该网站时,它会在不同的浏览器上给出不同的错误,这真的很烦人。下面是在不同浏览器上的错误描述
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/