在symfony只使用.htaccess的部队HTTPS [英] Force HTTPS using only HTACCESS in SYMFONY

查看:245
本文介绍了在symfony只使用.htaccess的部队HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个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]

这篇关于在symfony只使用.htaccess的部队HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆