在我的重写上强制使用HTTPS并统治.htaccess文件 [英] Force HTTPS on my rewrite and rule .htaccess file

查看:70
本文介绍了在我的重写上强制使用HTTPS并统治.htaccess文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上强制使用https,但是它与我的.htaccess的当前规则兼容

I would like to force https on my site but that it is compatible with the current rule of my .htaccess

此刻是我的htaccess文件:

Here is my htaccess file at the moment :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

谢谢

推荐答案

能否请您尝试以下操作,如果变量%{HTTPS} 是否打开,则需要在此处查找条件,请添加已经存在的条件.另外,请不要将其与现有的URL混合使用,因为它可能会暴露给客户端/浏览器(以您显示的当前示例为例).

Could you please try following, where you need to look for condition if variable %{HTTPS} is on or not, add this condition with already existing condition. Also please don't mix it with already existing URL as it may get expose to client/browser(taking example from your shown current example).

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

这篇关于在我的重写上强制使用HTTPS并统治.htaccess文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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