Force HTTPS on my rewrite and rule .htaccess file

ぐ巨炮叔叔 提交于 2021-01-28 02:32:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!