问题
I would like to force https on my site but that it is compatible with the current rule of my .htaccess
Here is my htaccess file at the moment :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Thanks
回答1:
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://stackoverflow.com/questions/64594041/force-https-on-my-rewrite-and-rule-htaccess-file