I want all traffic to the non-https example.com and www.example.com to be redirected to the https www.example.com with the exception of a certain path, i.e. http://www.example.com/import , /import/XXX, /import/YYY should stay http.
At the moment, I'm using the following to redirect all non-https traffic to https.
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
Which I think is where most of my problems are coming from when I try and do rewrites as I end up in a loop.
Update
I've enabled mod_rewrite logging and got the result:
... (2) init rewrite engine with requested uri /import/batch_name
... (3) applying pattern '^(.*)$' to uri '/import/batch_name'
... (1) pass through /import/batch_name
... (3) [perdir /var/www/] add path info postfix: /var/www/import -> /var/www/import/batch_name
... (3) [perdir /var/www/] strip per-dir prefix: /var/www/import/batch_name -> import/batch_name
... (3) [perdir /var/www/] applying pattern '^' to uri 'import/batch_name'
... (3) [perdir /var/www/] add path info postfix: /var/www/import -> /var/www/import/batch_name
... (3) [perdir /var/www/] strip per-dir prefix: /var/www/import/batch_name -> import/batch_name
... (3) [perdir /var/www/] applying pattern '^' to uri 'import/batch_name'
... (3) [perdir /var/www/] add path info postfix: /var/www/import -> /var/www/import/batch_name
... (3) [perdir /var/www/] strip per-dir prefix: /var/www/import/batch_name -> import/batch_name
... (3) [perdir /var/www/] applying pattern '^' to uri 'import/batch_name'
... (3) [perdir /var/www/] add path info postfix: /var/www/import -> /var/www/import/batch_name
... (3) [perdir /var/www/] strip per-dir prefix: /var/www/import/batch_name -> import/batch_name
... (3) [perdir /var/www/] applying pattern '(^|/)\.' to uri 'import/batch_name'
... (3) [perdir /var/www/] add path info postfix: /var/www/import -> /var/www/import/batch_name
... (3) [perdir /var/www/] strip per-dir prefix: /var/www/import/batch_name -> import/batch_name
... (3) [perdir /var/www/] applying pattern '^' to uri 'import/batch_name'
... (2) [perdir /var/www/] rewrite 'import/batch_name' -> 'index.php'
... (3) [perdir /var/www/] add per-dir prefix: index.php -> /var/www/index.php
... (2) [perdir /var/www/] strip document_root prefix: /var/www/index.php -> /index.php
... (1) [perdir /var/www/] internal redirect with /index.php [INTERNAL REDIRECT]
... (2) init rewrite engine with requested uri /index.php
... (3) applying pattern '^(.*)$' to uri '/index.php'
... (2) rewrite '/index.php' -> 'https://www.example.com/index.php'
... (2) explicitly forcing redirect with https://www.example.com/index.php
... (1) escaping https://www.example.com/index.php for redirect
... (1) redirect to https://www.example.com/index.php [REDIRECT/301]