本文介绍了如何使SSL + mod_rewrite + Zend Framework MVC协同工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有ZF MVC网站,并想在我的/checkout/下的所有内容上强制进行SSL连接我尝试为此使用mod_rewrite,所以我的.htaccess看起来像这样:

So, I got ZF MVC site and want to force SSL connection on everything under my /checkout/I tried using mod_rewrite for that, so my .htaccess would look like this:

RewriteEngine on
RewriteRule (\/checkout.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R]
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav)$ index.php [L]

当然,它确实可以使用SSL,但第二条规则是ZF特定的,并将所有内容重定向到index.php sorta会删除协议规范.

Sure enough, it does kick in SSL, but second rule, that's ZF specific and redirects everything to index.php sorta erases the protocol specification.

不幸的是,我对mod_rewrite的熟练程度非常糟糕.也许有人可以帮我解决这个问题?

Unfortunately my level of proficiency with mod_rewrite is stupendously terrible. Maybe someone could help me out to solve this?

推荐答案

蒂姆·莱特尔(Tim Lytle)的答案就在那里.

Tim Lytle's answer is mostly there.

我将其更改为更加严格地检查HTTPS,并且标志需要使用定界符.

I'd change it be a little more strict in checking HTTPS and the flags need a delimiter.

RewriteCond %{HTTPS} !^on$
RewriteRule ^/checkout/? https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav)$ index.php [L]

这篇关于如何使SSL + mod_rewrite + Zend Framework MVC协同工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 11:31