0

I am trying to modify my .htacess file to enforce https, but because I already have some rules, I just appear to be breaking it. Can anyone help advise me?

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|    (.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
Andriy Lozynskiy
  • 2,444
  • 2
  • 17
  • 35
  • Possible duplicate of [htaccess redirect to https://www](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) – localheinz Aug 12 '17 at 22:15

3 Answers3

1

Use the RewriteEngine. This will force ssl.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Goldbug
  • 605
  • 6
  • 8
1

You can try:

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

You can also check this link out. You have a lot of other rules you might need.

moonflare
  • 279
  • 1
  • 4
  • 11
0

I do this:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Rob Ruchte
  • 3,569
  • 1
  • 16
  • 18