使用mod_rewrite强制SSL / HTTPS [英] Force SSL/HTTPS with mod_rewrite
本文介绍了使用mod_rewrite强制SSL / HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Zend Framework应用程序,我想使用mod_rewrite强制进入HTTPS。当谈到mod_rewrite时,我很迷茫。这是我当前的.htaccess文件在我的应用程序的根目录。
I have a Zend Framework application that I want to force into HTTPS using mod_rewrite. I am pretty lost when it comes to mod_rewrite. Here is my current .htaccess file in the root of my application.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule !\.(html|htm|php|js|ico|gif|jpg|png|css|csv)$ /subdir/index.php
根据我拥有的内容强制应用程序进入HTTPS的最佳方法是什么?我已经尝试了一些我在这里找到的例子,但是当我尝试它时,我一直得到重定向循环或内部服务器错误。
What is the best way to force the application into HTTPS based on what I have? I have tried a couple of the examples I found on here, but I keep getting redirect loops or internal server errors when I try them.
感谢您的帮助!
推荐答案
将此规则放在当前规则之前:
Put this rule before your current rules:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
这篇关于使用mod_rewrite强制SSL / HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文