At wits end with this. My project setup below:
static web hosting: www.myproject.com
+subdomain api.myproject.com
+A record -> AWS Beanstalk
API (Beanstalk)
+/v1 non HTTPS
+/v2 HTTPS
I need to enforce HTTPS on api.myproject.com/v2
but allow non encrypted traffic to continue flowing to api.myproject.com/v1
Below is my current htaccess. I've tried many variations based on my reading, all fail. I AM able to redirect all www traffic, so I know the file can be effective.
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^api\.myproject\.com$ [NC]
RewriteCond %{REQUEST_URI} v1
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I read this as IF NOT https AND host is api.myproject.com AND uri contains v1 THEN redirect to HTTPS. Thanks