在我的重写上强制使用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]