HTTP到HTTPS重定向静态到动态URL


HTTP to HTTPS redirecting static to dynamic URLs

我们在htaccess文件中添加了HTTP到HTTPS重定向规则。。。。

RewriteCond %{HTTP_HOST} ^domain.co.uk [NC]
RewriteRule ^(.*)$ https://www.domain.co.uk/$1 [L,R=301]

一般来说,这很好,但当它应用于子文件夹中重写的URL时,它会将其转换回动态URL例如

http://www.domain.co.uk/make/model/将转换为https://www.domain.co.uk/product.php?make=htc&型号=一m9

我们真正需要的URL只是直接移动到https://

我使用以下方法,它一直对我很有效:

# force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]