0

I am a bit out of my depth when it comes to most server tasks so bear with me on my descriptions and understanding...

I am trying to use htaccess to force https across domain with Angular app in a subdirectory.

Project structure

/ public
  - .htaccess
  - index.html
  - styles.css
  - main.js
  - etc...
  / admin (angular app)
    - .htaccess
    - index.html
    - etc...

I am trying to force https across the whole domain while still being able to deep link to the /admin (angular) routes.

/public/.htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} ^site\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.^site\.co\.uk$
RewriteRule ^(.*)$ https://www.site.co.uk/$1 [R,L]

/public/admin/.htaccess

RewriteEngine on
RewriteOptions inherit
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]

All /admin routes are still accessible via plain http and are not redirected. I have tried various combinations of ${SERVER_PORT} & ${HTTPS} but these never trigger. It always seems to return port 80 and https off and causes "too many redirects".

  • Possible duplicate of [.htaccess not redirecting http to https](https://stackoverflow.com/questions/45665554/htaccess-not-redirecting-http-to-https) – akond Aug 14 '17 at 06:57
  • @akond that doesn't address my issues (unless I'm not understanding why?). HTTPS redirect works on the root domain but not the /admin subdirectory. –  Aug 14 '17 at 09:28

0 Answers0