如果我们有一个域,比如login.abc.com, 这个域我们同时接受http和https协议,但是我们希望将http协议的用户重定向到https,可以有两种做法,一种是在代码中进行重定向,zf的代码如下:

  1. class Common_Helper_ForceHTTPS extends Zend_Controller_Action_Helper_Abstract {  
  2.   public function direct() {  
  3.     if (! isset ( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS']) {  
  4.       $request = $this->getRequest ();  
  5.       $url = 'https://' . $_SERVER ['HTTP_HOST'] . $request->getRequestUri ();  
  6.       $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'redirector' );  
  7.       $redirector->gotoUrl ( $url );  
  8.     }  
  9.   }  
  10. }  


还有一种是进行配置,由于的配置是c代码,效率较高,我们建议用的配置来实现。

  1. <IfModule mod_rewrite.c> 
  2.     RewriteEngine on  
  3.     Options +FollowSymLinks  
  4.     RewriteBase /     
  5. RewriteCond %{REQUEST_FILENAME} !-f  
  6.     RewriteCond %{REQUEST_FILENAME} !-d     
  7.     RewriteRule ^(.*)$ index.php/$1  
  8.      
  9.     RewriteCond $1 !^(index.php|img|css|js|secure_checkout|common_funcs.js|robots.txt)  
  10.     RewriteCond %{SERVER_PORT} 80  
  11.     RewriteRule /secure_checkout(.*)$ https://www.myURL.com/secure_checkout/$1  
  12. </IfModule> 
  13. RewriteCond %{REQUEST_FILENAME} !-f  
  14.     RewriteCond %{REQUEST_FILENAME} !-d     
  15.     RewriteRule ^(.*)$ index.php/$1  
  16.      
  17.     RewriteCond $1 !^(index.php|img|css|js|secure_checkout|common_funcs.js|robots.txt)  
  18.     RewriteCond %{SERVER_PORT} 80  
  19.     RewriteRule /secure_checkout(.*)$ https://www.myURL.com/secure_checkout/$1  
  20. </IfModule>  

本日志由 huzi 于 2008-10-12 17:09:49 发表到 学习随笔 中,目前已经被浏览 880 次,评论 0 次;

作者添加了以下标签: 强制使用httpsapache设置

 用于IISHttp.sys注册表设置
概要
Microsoft Windows Server 2003 中,Http.sys 是处理 HTTP 请求的内核模式驱动程序。根据特定要求,可以配置多个注册表值。更多信息部分中的表包含有关这些注册表值的以下信息:
  • 注册表项名称
  • 默认值
  • 有效值范围
  • 注册表项功能
  • 警告代码(如果适用)

本日志由 huzi 于 2008-09-14 18:21:48 发表到 学习随笔 中,目前已经被浏览 933 次,评论 0 次;

作者添加了以下标签: IISHttp.sys注册表设置参数

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文