0

I am trying to redirect to https, and fairly certain Ive written my htaccess correctly, but Its not redirecting for some reason. Any help is much appreciated.

#
RewriteEngine on


#### TJOSELFSTORAGE ####
RewriteCond %{ENV:CARET_ENV} live [NC]
RewriteCond %{HTTP_HOST} !^www.tjoselfstorage.com$ [NC]
RewriteCond %{HTTP_HOST} ((.*).(org|net|com)|(.*).(.*).(org|net|com)|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}) [NC]

RewriteRule ^(.*)$ https://www.tjoselfstorage.com/$1 [R,L]


RewriteRule (^/images.*) https://www.tjoselfstorage.com? [R=301,L]



RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !__\^.php
RewriteRule ^(.*)/$ /$1 [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f [OR]

RewriteCond %{REQUEST_FILENAME} !resources

RewriteCond %{REQUEST_FILENAME} !__\^.php
RewriteRule (.*) \__\^.php/$0 [L

]

  • 1
    Possible duplicate of [Force SSL/https using .htaccess and mod\_rewrite](https://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite) – JoshKisb Jan 10 '18 at 21:16
  • I tried adding that, but then I got stuck in a loop. Is there something on the bottom half of my htaccess file that is causing this? – Dayna Dukett Jan 10 '18 at 22:24

1 Answers1

0

This is the preferred method of redirecting http to https straight from Apache's documentation:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
GuidedHacking
  • 3,628
  • 1
  • 9
  • 59