Ilann Joaquim
Ilann Joaquim

Reputation: 21

Force HTTPS on my rewrite and rule .htaccess file

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

Upvotes: 2

Views: 65

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133508

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]

Upvotes: 2

Related Questions