0

I have a React app on myapp.com which has SSL certificate installed. When I enter myapp.com in the browser, it goes to https://myapp.com as expected. If I navigate to /shop from there, it's still secured.

But the problem is when I enter myapp.com/shop manually in the url. Then the connection is not secured.

Here is my .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]

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

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Armin Dervić
  • 165
  • 2
  • 11

1 Answers1

1

You're missing the flags of the rewrite rule [R,L]

Full code:

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Another best practice would be to change the HTTPS check with the port check, but this is optional as your code should work fine too.

RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Andrea Olivato
  • 2,450
  • 1
  • 18
  • 30