我们有一个Symfony的1.4项目,并正在寻求强制HTTPS仅使用htaccess的文件在symfony应用程序的所有页面。我知道有办法使用过滤器做的,但我想知道,如果它可以做到不首先?
We have a Symfony 1.4 project and are looking to force https for all pages in a symfony application using only the htaccess file. I know there are ways to do using filters but I want to know if its possible to do without that first?
下面是我目前正在使用,但不工作的.htaccess文件如预期...
Here is the .HTACCESS file I currently am using but isn't working as expected...
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
我也尝试没有成功:
I've also tried without success:
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
我相信有一些怪癖,我在Symfony的这样做,因为这是一件容易的事做直线距离失踪。任何想法男士?
I am sure there is some quirk I am missing in doing this with Symfony as this is an easy task to do straight away. Any ideas gents?
对于一个 previous答案,尝试
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R,L]