如果我们有一个域,比如login.abc.com, 这个域我们同时接受http和https协议,但是我们希望将http协议的用户重定向到https,可以有两种做法,一种是在代码中进行重定向,zf的代码如下:
- class Common_Helper_ForceHTTPS extends Zend_Controller_Action_Helper_Abstract {
- public function direct() {
- if (! isset ( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS']) {
- $request = $this->getRequest ();
- $url = 'https://' . $_SERVER ['HTTP_HOST'] . $request->getRequestUri ();
- $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'redirector' );
- $redirector->gotoUrl ( $url );
- }
- }
- }
还有一种是进行apache配置,由于apache的配置是c代码,效率较高,我们建议用apache的配置来实现。
- <IfModule mod_rewrite.c>
- RewriteEngine on
- Options +FollowSymLinks
- RewriteBase /
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ index.php/$1
- RewriteCond $1 !^(index.php|img|css|js|secure_checkout|common_funcs.js|robots.txt)
- RewriteCond %{SERVER_PORT} 80
- RewriteRule /secure_checkout(.*)$ https://www.myURL.com/secure_checkout/$1
- </IfModule>
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ index.php/$1
- RewriteCond $1 !^(index.php|img|css|js|secure_checkout|common_funcs.js|robots.txt)
- RewriteCond %{SERVER_PORT} 80
- RewriteRule /secure_checkout(.*)$ https://www.myURL.com/secure_checkout/$1
- </IfModule>
受用, 感谢.
可是我已经有好几次直接关闭了,应该怎么办呢?之前登录的用户还在
小站http://kkk.sjhcx.com/的SEO布局不知如何,请博主有空指点
来访既是有缘。。留下足迹再走
不错,感人,给力
不错也~~~~
就是,就是,现在的电影就看票房,完全没社会责任心
其实对于这个问题,我们应该淡定,平常心,平常心。
写的不错, 兔年快乐喽!!
哇,春节快乐, 这几天玩过头了
Powered by Bitrac, Designed by Loveyuki, Icon by Led Icon Set. 京ICP备07032740号-2