0

I've seen some related access but they seem to affect the routes themselves. Shouldn't I just be able to update the initial load to be https and then everything else would flow from there?

My site is setup like this:

/Root
  *client
    -app files
    -index.html
    -htaccess
  *server
    -server.js (express, node)

In the .htaccess file. I have:

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

What am I doing wrong? The .htaccess file apparently has no result? I want it to redirect to https:// when a user visits www., the root domain, or http://

Thank you for any help. Much appreciated.

Update: I've found another post that says this should work for me:

##Force SSL 

#Normal way (in case you need to deploy to NON-heroku)
RewriteCond %{HTTPS} !=on

#Heroku way
RewriteCond %{HTTP:X-Forwarded-Proto} !https 

#If neither above conditions are met, redirect to https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Unfortunately, it does not. Here is the post: How to redirect to HTTPS with .htaccess on Heroku Cedar stack

Community
  • 1
  • 1
EmptyPockets
  • 727
  • 1
  • 7
  • 23
  • If you use "http" to connect, then the HTTPS variable is not set at all. So if you compare an empty string to `off` it does not match and as a result no rewrite is made. You could do something like `RewriteCond %{HTTPS} !=on` – vstm Nov 30 '14 at 07:52
  • @vstm Thank you but unfortunately that had no result. – EmptyPockets Nov 30 '14 at 08:05
  • Does this answer your question? [AngularJS SSL .htaccess woes](https://stackoverflow.com/questions/30496174/angularjs-ssl-htaccess-woes) – Top-Master Feb 23 '20 at 11:40

1 Answers1

0

Apache redirection (using .htaccess) using a node server doesn't seem to work well together.

Stop Apache. Integrate redirection within your node express server file. Restart as a node server (sudo node server).

Pat M
  • 5,966
  • 7
  • 24
  • 34